hisoka Posted April 8, 2015 Posted April 8, 2015 floor division is a mathematical division that rounds down to nearest integer. 89 / 45 gives 1.9777777777777779 meanwhile 89//45 gives 1 why not 2 ? 2 is the nearest integer to 1,97777777777777777779 and not 1 so normally it should give 2 not 1 98.45//56.54 gives 1.0 why not 1 ? why 1.0 I consider it as a mistake from the people who invented python as it must give 1 and not 1.0 for example 90/45 = 2.0 meanwhile 90//45 gives 2
davej Posted April 8, 2015 Posted April 8, 2015 If you want rounding then you use a rounding function. Another option is a formatting function.
justsomeguy Posted April 8, 2015 Posted April 8, 2015 You even quoted the exact definition: floor division is a mathematical division that rounds down to nearest integer.What do you think "rounds down to the nearest integer" means?
hisoka Posted April 8, 2015 Author Posted April 8, 2015 (edited) 1,97 is between 1 and 2 and the nearest number to 1,97 is 2 so 1,97 when rounded to the nearest , it becomes 2 and not 1 . and 1,97 is rounded up not down because the last digit is greater than 5 What do you say about that? Edited April 8, 2015 by hisoka
justsomeguy Posted April 8, 2015 Posted April 8, 2015 I say that you need to be better at reading: floor division is a mathematical division that rounds down to nearest integer.Floor always rounds down. That's why it is called floor. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now