Log In  

I discovered tonight that the modulo (%) operator is treating the nadir value, 0x8000, as if it is positive, whereas other math ops treat it as negative:

> ?0x7ffe/10
3276.6
> ?0x7fff/10
3276.7
> ?0x8000/10
-3276.8            <-- as expected, -32768/10 == -3276.8
> ?0x8001/10
-3276.7
> ?0x8002/10
-3276.6

> ?0x7ffe%10
6
> ?0x7fff%10
7
> ?0x8000%10
8                  <-- unexpected, -32768%10 should be 2
> ?0x8001%10
3
> ?0x8002%10
4

I'm guessing this is an edge-case side effect of whatever you do to make modulo not flip directions at 0 (which I'm very glad you do).

P#52738 2018-05-14 14:57 ( Edited 2018-05-14 19:02)


[Please log in to post a comment]