4 Answers
+ 6
-4 is the largest integer less than or equal to -3.6666666666666....
+ 4
11/3 = 3.66666
11//3 = 3 (floor value is 3)
-11//3 = -4 (floor value of -3.6 is -4)
+ 1
Yeah got it tq all
+ 1
I think thats because // and % have something common.
If we think that a % b = a - (a//b)*b
And 0 <= a % b < b, when b > 0
(0 >= a % b > b, when b < 0)
If for example -8 // 3 = -2, then -8 % 3 = -8 - (-2)*3 = -2 and -2 < 0 which should not happen because -8 % 3 = 1
This problem would appear almost always when a <= 0 and b > 0 (exception case when a % b = 0).
But if -8 // 3 = -3, then -8 % 3 = -8 - (-3)*3 = 1 and it would be correct.