nathanletwory
(Nathan 'jesterKing' Letwory)
March 1, 2023, 5:41am
2
This is how floating points work on computers.
As mentioned multiple times on this forum don’t assume bit-for-bit parity when working with floating point numbers (single or duouble precision).
Further, Python does its own things to numbers when printing, so don’t rely on that either.
What may make sense to you as a normal human being does no longer hold in the realm of floating point computation and even just floating point representation in computer memory.
You can use the EpsilonEquals() utility functions provided by Rhino.RhinoMath:
…
From the Python floating point tutorial perhaps my favourite bit is this:
print ( 0.1 + 0.1 + 0.1 == 0.3)
Just paste that in EditPythonEditor and run it
Some numbers cannot be represented exactly. But if you look at it you’ll see that it is many, many places after the decimal comma. So essentially they are the same.
1 Like