3 ms·
I like the concept - really nice. It would be cool to see an update of Calculize use a math library instead of JavaScript numbers. In Calculize: a = 1/
by autotelicum 15y ago
I like the concept - really nice. It would be cool to see an update of Calculize use a math library instead of JavaScript numbers.
In Calculize:
a = 1/3
show a+a+a+a+a+a == 6*a
# => false
show pow 9,18
# => 150094635296999140
# should be: 150094635296999121
show 150094635296999122 - 150094635296999121
# => 0
In Python 2.6.1:
>>> p = 1.0/3.0
>>> p+p+p+p+p+p == 6*p
False
>>> pow(9,18)
150094635296999121
>>> 150094635296999122 - 150094635296999121
1
These minuscule rounding errors are inconsequential for most apps, but for math...
Maybe the results will also vary between browsers, because EcmaScript talks of implementation-dependent approximation's.
[Edit: Oops, python got me with it's own quirk - division needs to be from the __future__ or it's integer]