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
All we would really need to do is to have a check in our comparators for real and use the math.isclose() if we wanted a more natural model for floating point arithmetic. Alternatively, we could implement our own isclose to mirror the underlying implementation.
The text was updated successfully, but these errors were encountered:
That's real bad. I thought, may be this is due to the way we might be interacting with Python but no,
lutz$ python3
Python 3.8.9 (default, Oct 26 2021, 07:25:53)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.1 + 0.1 == 0.3
False
>>>
The function isclose already exists in our math module. Perhaps we should issue a warning when folks try to do an exact comparison on reals...
lutzhamel
changed the title
Need to account for python precision errors in floating point arithmetic
issue warning when user performs an exact comparison on reals
Feb 17, 2023
Because python's underlying floating point arithmetic has precision errors, the following program prints out false:
All we would really need to do is to have a check in our comparators for
real
and use themath.isclose()
if we wanted a more natural model for floating point arithmetic. Alternatively, we could implement our ownisclose
to mirror the underlying implementation.The text was updated successfully, but these errors were encountered: