|
From: Greg C. <chi...@co...> - 2005-01-26 19:49:51
|
On 2005-01-26 02:48 AM, Danny Smith wrote:
>
> If we restrict domain of an our asm __expm1 to (-.5*M_LN2, +.5*M_LN2), than much
> of the code
> in exp() is really unnecessary. We don't need to worry about the integral part
> of the separaton
>
> x log2(e) = i + f, |f| <= .5
How about this?
static long double expm1l (long double x)
{
if (-M_LN2 < x && x < M_LN2)
{
x *= M_LOG2E;
__asm__("f2xm1\n\t" : "=t" (x) : "0" (x));
return x;
}
else
return expl(x) - 1.0L;
}
It passes my unit tests with MinGW gcc-3.4.2 .
The domain is (-M_LN2, +M_LN2) because F2XM1's input is
constrained to (-1, +1). Maybe intel means [-1, +1], but
their documentation is unclear as to whether the interval
is open or not, so it's safer to assume it's open.
|