blob: 1c4fdf0278710b33a6997c971595f09abe349832 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
Modulus operator
----------------
How should the modulus operator work with negative operands?
r = a mod b
For `a`, I think it should work as follows:
a -5 -4 -3 -2 -1 0 1 2 3 4 5
b 3 3 3 3 3 3 3 3 3 3 3
r 1 2 0 1 2 0 1 2 0 1 2
For `b`, I think negative values are counter-intuitive.
For now I will simply disallow negative values.
(It is already required that it must be <> 0, so it actually
only simplifies the code)
|