You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
You have all been very naughty!
Look at the following Christmas bug Santa has brought…
The problem concerns the builtin function round().
In its current implementation, rounding is done to the nearest float that can be represented by the machine.
This is wrong, rounding should be done to the nearest float with the correct least significant decimal that can be represented by the machine.
You have all been very naughty!
Look at the following Christmas bug Santa has brought…
The problem concerns the builtin function
round()
.In its current implementation, rounding is done to the nearest float that can be represented by the machine.
This is wrong, rounding should be done to the nearest float with the correct least significant decimal that can be represented by the machine.
Consider the following little
main.py
script:Here is the output on a PyBoard:
Things are not any different on a Pycom LoPy ESP32:
Note that the difference between correct and erroneous rounding is about a 1000 times the machine epsilon, which makes sense.
For certain applications, such poor rounding can have very serious consequences down the line…
This finding may account for the multitude of other reports complaining about
round()
behaviour:The text was updated successfully, but these errors were encountered: