mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Improve clog, clog10 handling of values with real or imaginary part 1 (bug 13629).
This commit is contained in:
@ -44,21 +44,21 @@ __clog10 (__complex__ double x)
|
||||
{
|
||||
/* Neither real nor imaginary part is NaN. */
|
||||
double absx = fabs (__real__ x), absy = fabs (__imag__ x);
|
||||
double d;
|
||||
int scale = 0;
|
||||
|
||||
if (absx < absy)
|
||||
{
|
||||
double t = absx;
|
||||
absx = absy;
|
||||
absy = t;
|
||||
}
|
||||
|
||||
if (absx > DBL_MAX / 2.0)
|
||||
{
|
||||
scale = -1;
|
||||
absx = __scalbn (absx, scale);
|
||||
absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0);
|
||||
}
|
||||
else if (absy > DBL_MAX / 2.0)
|
||||
{
|
||||
scale = -1;
|
||||
absx = (absx >= DBL_MIN * 2.0 ? __scalbn (absx, scale) : 0.0);
|
||||
absy = __scalbn (absy, scale);
|
||||
}
|
||||
else if (absx < DBL_MIN && absy < DBL_MIN)
|
||||
{
|
||||
scale = DBL_MANT_DIG;
|
||||
@ -66,9 +66,27 @@ __clog10 (__complex__ double x)
|
||||
absy = __scalbn (absy, scale);
|
||||
}
|
||||
|
||||
d = __ieee754_hypot (absx, absy);
|
||||
if (absx == 1.0 && scale == 0)
|
||||
{
|
||||
double absy2 = absy * absy;
|
||||
if (absy2 <= DBL_MIN * 2.0 * M_LN10)
|
||||
{
|
||||
#if __FLT_EVAL_METHOD__ == 0
|
||||
__real__ result = (absy2 / 2.0 - absy2 * absy2 / 4.0) * M_LOG10E;
|
||||
#else
|
||||
volatile double force_underflow = absy2 * absy2 / 4.0;
|
||||
__real__ result = (absy2 / 2.0 - force_underflow) * M_LOG10E;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
__real__ result = __log1p (absy2) * (M_LOG10E / 2.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
double d = __ieee754_hypot (absx, absy);
|
||||
__real__ result = __ieee754_log10 (d) - scale * M_LOG10_2;
|
||||
}
|
||||
|
||||
__real__ result = __ieee754_log10 (d) - scale * M_LOG10_2;
|
||||
__imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user