I am trying to calculate the floor value of certain numbers.
It works fine when I run this: math.floor(9.999999999999999)
.
I get the output as 9
. This number has 15 decimal places.
However, math.floor()
seems to fail after 15 decimal places.
When I run this: math.floor(9.9999999999999999)
, I get the output as 10
. This number has 16 decimal places.
I want to understand why math.floor()
is rounding up the number after 15 decimal places.
NOTE :
Somehow, adding 1
after the 15th decimal place also works correctly.
Input : math.floor(9.9999999999999991111)
Output : 9
However, any other number besides 1
, and the number gets rounded up.
Input : math.floor(9.9999999999999992)
Output : 10
I would like to understand the reason for this unusual behavior in python.