4 ms·
You get the same behaviour with regular floats: >>> a=10.0**10 >>> a 10000000000.0 >>> b = 0.1 >>> b+a 10000000000.1 >>> c=b+a
by anon4 12y ago
You get the same behaviour with regular floats:
>>> a=10.0**10
>>> a
10000000000.0
>>> b = 0.1
>>> b+a
10000000000.1
>>> c=b+a
>>> d=c-a
>>> d
0.10000038146972656
>>> d == b
False
>>> a + b - b == b
False
>>>
You could build a variable-tracking system on top of the numbers, or you could just use a symbolic computation package, then simplify the final equations so each variable figures only once.