0
Modulo with negative numbers
Can someone explain why these 2 lines in code give different results https://code.sololearn.com/ctGo1AQLJ1Vr/?ref=app
1 Réponse
+ 1
6%-4 = 2 because
6/-4 = -1 + R/-4
R = 6 - (-1*-4) = 6 - (+4) = 2
-6%4 = -2 because
-6/4 = -1 + R/4
R = -6 - (-1*4) = -6 - (-4) = -2