Skip to content

Fix Mod operator

Olivier Antoni requested to merge (removed):mod_operator into dev

This MR corrects the sign of the result in the case of a negative divisor or dividend.

The sign of the result of the % operator in C++ is that of the dividend:

7 % (-3) = 1
(-7) % 3 = -1

The expected sign of the result of the [Mod] operator is that of the divisor:

7 Mod (-3) = -2 (and not 1)
(-7) Mod 3 = 2 (and not -1)
Edited by Olivier Antoni

Merge request reports

Loading