+ 2

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?

1st Feb 2020, 4:47 AM
Zaed _
Zaed _ - avatar
6 Respuestas
+ 6
1st Feb 2020, 6:25 AM
Oma Falk
Oma Falk - avatar
+ 4
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
1st Feb 2020, 5:38 AM
Ashif T
+ 4
Oma Falk, thank you for oyur sample. I have extended it with floor() and ceil(). https://code.sololearn.com/cPjC9CFr1DSv/?ref=app
1st Feb 2020, 8:25 AM
Lothar
Lothar - avatar
+ 2
Lothar perfect!
1st Feb 2020, 8:58 AM
Oma Falk
Oma Falk - avatar
+ 2
I want to add a little detail: If you string up enough 9 in the decimals, it will be rounded up! https://www.sololearn.com/discuss/2149084/?ref=app
1st Feb 2020, 9:49 AM
HonFu
HonFu - avatar