Dear List Members,
I have calculated (-2) mod (-3) according to the formal definition (page
51 of CL standard). The result is -5 (because (-2) rem 3 is -2).
Moreover, x mod (-3) maps to the set { -5, -4, 0, 1, 2 } depending on x,
which is not a continuous interval. I think there is a mistake in the
definition.
In my opinion the result of a modulo division for a negative divisor
should be the same as for positive divisor. That is, x mod y should be
equal to x mod |y| by definition, if y < 0.
That is, the last rule of the definition would be better if it was:
x mod y = ...
|y| + x rem |y| if x < 0 and x rem |y| < 0
and (-2) mod (-3) would result in 3 + (-2) = 1, which is more reasonable
than -5.
Am I right or you have other ideas?
Regards
Zoltan
--
János Zoltán Szabó [ETH/RL/S] This email address is being protected from spambots. You need JavaScript enabled to view it.
Tel.: +36-1-437-7635, Fax: +36-1-437-7767
Ericsson Telecommunications Ltd., 1037 Budapest, Laborc u. 1., Hungary