0

Why (-5//2) = -3?

Please explain this. #python

2nd Sep 2020, 3:04 AM
1971 • Anas
1971 • Anas - avatar
3 ответов
+ 2
It divides: -5/2=-2.5, and then makes it the integer below (-3). a//b == math.floor(a/b)
2nd Sep 2020, 3:26 AM
Nikolai Ivanov
Nikolai Ivanov - avatar
+ 3
Anash🇧🇩 The result of // operator is similar to floor division result. Follow number line concept ..... -3 -2 -1 0 1 2 3 ... 5/2= 2.5 next lower value is 2 So 5//2 =2 -5/2= -2.5 next lower value is -3 So -5//2= -3 Check math.floor() method
2nd Sep 2020, 3:20 AM
Ajith
Ajith - avatar
+ 1
Ajith Nikolai Ivanov Thank you so much... Nice explain.
2nd Sep 2020, 3:29 AM
1971 • Anas
1971 • Anas - avatar