hisoka

python math

6 posts in this topic

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

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

If you want rounding then you use a rounding function. Another option is a formatting function.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 by hisoka

Share this post


Link to post
Share on other sites

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 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now