Konubinix' opinionated web of thoughts

Floating Point Error Simply Put

fleeting

floating point error simply put

Floating points number are not able to encode 0.1.

import decimal
decimal.Decimal(0.1)
0.1000000000000000055511151231257827021181583404541015625

Therefore, 0.1 added 10 times does not equal to 1.0

0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0
False

But, due to precision approximation, 0.9 and 0.1 equal to 1.0.

0.9 + 0.1 == 1.0
True