Does 'int' in Python 3.6 round backwards only? | Sololearn: Learn to code for FREE!


Does 'int' in Python 3.6 round backwards only?

For example, I'm using int in my code and it's turning 2/3*100 into 66 rather than 67... But why?

2/1/2020 4:47:25 AM

Zaed _

6 Answers

New Answer


a oneliner can clear the case


Here are some interesting sources for the float inaccuracy problem. It's weekend, so we have time to dive in it.


Yes,it only gives you the value backwards,even if your value is 66.99 ,if you want forward no you can use "ceil" function from math module


Oma Falk, thank you for oyur sample. I have extended it with floor() and ceil().


Lothar perfect!


I want to add a little detail: If you string up enough 9 in the decimals, it will be rounded up!