[Haskell-cafe] floating point operations and representation
Ketil Malde
ketil at malde.org
Thu Mar 13 05:12:46 EDT 2008
"Jacob Schwartz" <quark at bluespec.com> writes:
> A test on IEEE computers (x86 and x86-64), shows that for
> a range of 64-bit "double" values, the answers in C do differ (in the
> last bit) if you use "log2(x)" and "log10(x)" versus "log (x) /
> log(2)" and "log(x) / log(10)".
I think this may also depend on C compiler and optimization level.
Perhaps now everybody uses SSE to do math, but earlier Intel FPU
architectures did floating point with 80-bit registers, so the
accuracy of the result could depend on whether an intermediate result
was flushed to memory (by a context switch).
Equality on floating point is tricky, if I were you, I'd round the
results before comparing.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list