+ 2

usage of floor division

print(20//6)=3 print(20.0//6)=3.0 print(20.15//6)=3.0 So the rounded decimal part can only be one bit at most, right?

14th Oct 2021, 1:31 AM
xiaroubai
xiaroubai - avatar
1 ответ
+ 5
Hi! Of course, you're correct. But, floor division and floating-point numbers simply are fundamentally incompatible and you should never use // on floats. For that, you can use integers or math.floor() instead. https://stackoverflow.com/questions/44681860/why-does-integer-division-return-float
14th Oct 2021, 2:42 AM
Python Learner
Python Learner - avatar