
13 Mar
2008
13 Mar
'08
5:12 a.m.
"Jacob Schwartz"
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