mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Fix clog, clog10 spurious underflow exceptions (bug 14337).
This commit is contained in:
@ -43,25 +43,30 @@ __clog10l (__complex__ long double x)
|
||||
else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
|
||||
{
|
||||
/* Neither real nor imaginary part is NaN. */
|
||||
long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x);
|
||||
long double d;
|
||||
int scale = 0;
|
||||
|
||||
if (fabsl (__real__ x) > LDBL_MAX / 2.0L
|
||||
|| fabsl (__imag__ x) > LDBL_MAX / 2.0L)
|
||||
if (absx > LDBL_MAX / 2.0L)
|
||||
{
|
||||
scale = -1;
|
||||
__real__ x = __scalbnl (__real__ x, scale);
|
||||
__imag__ x = __scalbnl (__imag__ x, scale);
|
||||
absx = __scalbnl (absx, scale);
|
||||
absy = (absy >= LDBL_MIN * 2.0L ? __scalbnl (absy, scale) : 0.0L);
|
||||
}
|
||||
else if (fabsl (__real__ x) < LDBL_MIN
|
||||
&& fabsl (__imag__ x) < LDBL_MIN)
|
||||
else if (absy > LDBL_MAX / 2.0L)
|
||||
{
|
||||
scale = -1;
|
||||
absx = (absx >= LDBL_MIN * 2.0L ? __scalbnl (absx, scale) : 0.0L);
|
||||
absy = __scalbnl (absy, scale);
|
||||
}
|
||||
else if (absx < LDBL_MIN && absy < LDBL_MIN)
|
||||
{
|
||||
scale = LDBL_MANT_DIG;
|
||||
__real__ x = __scalbnl (__real__ x, scale);
|
||||
__imag__ x = __scalbnl (__imag__ x, scale);
|
||||
absx = __scalbnl (absx, scale);
|
||||
absy = __scalbnl (absy, scale);
|
||||
}
|
||||
|
||||
d = __ieee754_hypotl (__real__ x, __imag__ x);
|
||||
d = __ieee754_hypotl (absx, absy);
|
||||
|
||||
__real__ result = __ieee754_log10l (d) - scale * M_LOG10_2l;
|
||||
__imag__ result = M_LOG10El * __ieee754_atan2l (__imag__ x, __real__ x);
|
||||
|
Reference in New Issue
Block a user