+ 1
When adding 0.2 to 0.1 in python why is the sum 0.30000000000000004?
2 Respostas
+ 3
Computers use binary numbers so do python.
Some decimal numbers cannot be expressed exact in binary (infinite binary number) so computer do an aproximation.
+ 1
Same questions in other sites too, have a look and the reason behind it:
https://stackoverflow.com/questions/7545015/can-someone-explain-this-0-2-0-1-0-30000000000000004
https://betterprogramming.pub/why-is-0-1-0-2-not-equal-to-0-3-in-most-programming-languages-99432310d476