HaloO,

Darren Duncan wrote:
Following from this, I propose that we have distinct-looking operators (not just multis) that users can explicitly choose when they want to do integer division/modulus or non-integer division/modulus.

For example, we could have:

  div - integer division
  mod - integer modulus
  /   - number division
  %   - number modulus

May I use this to remind the list that I proposed to define the
modulus in the most algebraically pleasing way, i.e. in the
Euclidean definition.
(See http://www.cs.uu.nl/~daan/download/papers/divmodnote-letter.pdf)

That is we define % and mod as the saw-tooth function that
has jumps at every integer multiple of the absolute value of
the modulus:
          ^ y
          |_m
     /   /|  /   /   /   /
    /   / | /   /   /   / x % m
   /   /  |/   /   /   /
 -*---*---*---*---*---*--> x
-2m  -m   0   m  2m  3m

E.g. 3.2 % 2.4 == 3.2 % -2.4 == 0.8

This definition is most useful when it comes to defining the modulus
for classes that fit the underlying axioms of an (euclidean) integral domain. E.g. this modulus is also defined for Complex numbers.


Regards, TSa.
--

Reply via email to