+ 4

Why does // throw out the wrong number here by rounding down?

https://code.sololearn.com/cMJVH8flurZf/?ref=app

2nd Apr 2022, 2:55 PM
Didi
Didi - avatar
5 Réponses
+ 5
Didi Hope you will find your answer here. https://stackoverflow.com/questions/38588815/rounding-errors-in-JUMP_LINK__&&__python__&&__JUMP_LINK-floor-division Edit: I didn't understand the problem at first.
2nd Apr 2022, 3:16 PM
Adil
Adil - avatar
+ 3
Yeah but 1000/1.6 is 625....
2nd Apr 2022, 3:05 PM
Didi
Didi - avatar
+ 2
Because "//" is the floor division operator and rounds down the result to the nearest integer. To understand more about it, check it out: https://www.codingem.com/JUMP_LINK__&&__python__&&__JUMP_LINK-floor-division/ Hope it helps! Happy Coding 🤠
2nd Apr 2022, 3:03 PM
Adil
Adil - avatar
+ 2
Thanks, I won't use the floor operator then because of the rounding issue and use int(x/y) instead. 👍💐
2nd Apr 2022, 3:26 PM
Didi
Didi - avatar