Dec-02-2018, 07:39 AM
The python float 0.1 is not exactly equal to the same mathematical number because computers store numbers in binary form and the real number 0.1 cannot be represented exactly in base 2 on 64 bits. This is not a limitation of python, it is a limitation of the widely adopted IEEE754 floating point format used by computers. The true value of 0.1 in your program is
>>> (0.1).as_integer_ratio() (3602879701896397, 36028797018963968)You can read this documentation page for more.