Questions arise when I type in these expressions to Python 3.3.0
-10 // 3 # -4 -10 % 3 # 2 10 // -3 # -4 10 % -3 # -2 -10 // -3 # 3
A simple rule: for a % b = c, if c is not zero, then should have the same sign as b.
a % b = c
c
b
And apply the magic formula:
10 % -3 = -2 => 10 // -3 = (10 - (-2)) / (-3) = -4
10 % -3 = -2
10 // -3 = (10 - (-2)) / (-3) = -4
-10 % 3 = 2 => -10 // 3 = (-10 - 2) / 3 = -4
-10 % 3 = 2
-10 // 3 = (-10 - 2) / 3 = -4
-10 % -3 = -1 => -10 // -3 = (-10 - (-1)) / (-3) = 3
-10 % -3 = -1
-10 // -3 = (-10 - (-1)) / (-3) = 3