+ 1
Can anyone explain this
#py -15//10 #output : -2.0
2 Answers
+ 3
// truncates fractional parts, which means rounding towards negative infinity. This direction of rounding is the same for positive and negative numbers, so -1.5 is rounded to -2.
Side note: the output is -2, not -2.0, since // yields an integer
+ 2
10 ---> 0 {the first time}
0 ---> -10 {the second time}
For your purpose, use -(15//10).