Under some circumstances
the log10() function for a double returns 0.0 for all
arguments.
Yes, this is a known problem in log10 in 64-bit running on Intel
that appeared in 10.5.2. Some of the 32-bit ABI assumptions
leaked through to the 32-bit implementation: the code assumes
the input, x, is available on the stack where it would be in 32-bit
code.
There are a couple ways to work around this:
1. A simple fix in C code (at some small cost in accuracy and speed):
const double Log10_of_2 = 0x1.34413509F79FFp-2;
log2(x)*Log10_of_2
2. For an accurate log10 (with about the same performance):
use this assembly wrapper
// log10fix.s: Workaround for log10 on Intel 64-bit OS X 10.5.2
// Add this file to xcode project or compile with -lm
#if defined(__x86_64__)
.text
.globl _log10
.align 4
_log10:
sub $8, %rsp
movsd %xmm0, (%rsp)
callq _log10$fenv_access_off
add $8, %rsp
ret
#endif
Cheers,
Jeff Kidder
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Scitech mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden