I'm getting -1
as output for -2//4
.
print(-2//4)
I'm getting -1
as output for -2//4
.
print(-2//4)
-2 divided by 4 == -0.5
In Python 3 the //
operator produces the floor of the result
Floor will bring the number to the next lower integer
You are working with negative numbers, hence -1
is less than 0
-2 / 4
>> -0.5
math.floor(-0.5)
>> -1
-2 // 4
>> -1