The reason is that floating point numbers aren’t decimal.
It’s literally impossible to represent 0.1 exactly in a floating point number. Computer can’t do it.
0.5, 0.25, 0.125, 0.0625, and other numbers that are even fractions of 2 are exactly representable.
The problem is that you’re doing this:
- Try to represent a value that’s exactly 0.1
- Present the value that’s stored above exactly
What you should be doing is:
- Represent whatever the number actually is
- Present the number with rounding in presentation, for example using
ToText (float)
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html