issue warning when user performs an exact comparison on reals
Because python's underlying floating point arithmetic has precision errors, the following program prints out false:
load system io.
io @println ( (.1 + .1 + .1) == .3 ).
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.
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
>>>
Ouch!
By extension this is true with standard C under both gcc and clang (The only two I've tested so far)!!
What do you all think the best solution here is? Have some standard epsilon we work with for tolerances or just give users something akin to isclose?
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...