To whom it may concern, My name is Yi-Ming Chang, I am writing this email to double check whether that is a bug in Python. [cid:image001.png@01D82E58.D5F1E830] I have searched online, they said this is binary float, but I am not is this an error in Python? Or there is a way to avoid it? Cheers, Yi-Ming
Hi Yi-Ming Chang,
I have searched online, they said this is binary float, but I am not is this an error in Python? Or there is a way to avoid it?
This is not a bug in Python, this is Python delegating the computation to your CPU, and it's not even an error from your CPU, it's a limitation in the binary representation used for the float numbers, like we have limitations to represent some values in our base 10 system (try to write 10/3 for example). To learn more about it: https://docs.python.org/3/tutorial/floatingpoint.html and https://0.30000000000000004.com/ If you really need more precision, you can use the Decimal module: https://docs.python.org/3/library/decimal.html Bests, -- Julien Palard https://mdk.fr
participants (2)
-
Julien Palard
-
Yi-Ming Chang