Message299082
Modulo is defined mathematically as the remainder of Euclidian division. I.E. a positive r where a % b = r is equivalent to a = b * x + r. I think it confuses the issue to say "-190 % 12 were the mathematical equivalent -10", when that is technically incorrect.
Computer modulo uses truncated division, which is why -a % b != a % -b.
"... compilers that truncate i // j need to make i % j have the same sign as i."
i % j has the same sign as j, not i. I believe that is the typo that has caused the confusion.
I would replace the last line with :
"-190 % 12 == -10 is wrong according to the C definition for computer modulo arithmetic." |
|
Date |
User |
Action |
Args |
2017-07-25 13:47:54 | wohlganger | set | recipients:
+ wohlganger, terry.reedy, mark.dickinson, docs@python |
2017-07-25 13:47:54 | wohlganger | set | messageid: <1500990474.68.0.537392208618.issue31021@psf.upfronthosting.co.za> |
2017-07-25 13:47:54 | wohlganger | link | issue31021 messages |
2017-07-25 13:47:54 | wohlganger | create | |
|