mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Fix clog, clog10 spurious underflow exceptions (bug 14337).
This commit is contained in:
@ -40,25 +40,30 @@ __clogf (__complex__ float x)
|
||||
else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1))
|
||||
{
|
||||
/* Neither real nor imaginary part is NaN. */
|
||||
float absx = fabsf (__real__ x), absy = fabsf (__imag__ x);
|
||||
float d;
|
||||
int scale = 0;
|
||||
|
||||
if (fabsf (__real__ x) > FLT_MAX / 2.0f
|
||||
|| fabsf (__imag__ x) > FLT_MAX / 2.0f)
|
||||
if (absx > FLT_MAX / 2.0f)
|
||||
{
|
||||
scale = -1;
|
||||
__real__ x = __scalbnf (__real__ x, scale);
|
||||
__imag__ x = __scalbnf (__imag__ x, scale);
|
||||
absx = __scalbnf (absx, scale);
|
||||
absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f);
|
||||
}
|
||||
else if (fabsf (__real__ x) < FLT_MIN
|
||||
&& fabsf (__imag__ x) < FLT_MIN)
|
||||
else if (absy > FLT_MAX / 2.0f)
|
||||
{
|
||||
scale = -1;
|
||||
absx = (absx >= FLT_MIN * 2.0f ? __scalbnf (absx, scale) : 0.0f);
|
||||
absy = __scalbnf (absy, scale);
|
||||
}
|
||||
else if (absx < FLT_MIN && absy < FLT_MIN)
|
||||
{
|
||||
scale = FLT_MANT_DIG;
|
||||
__real__ x = __scalbnf (__real__ x, scale);
|
||||
__imag__ x = __scalbnf (__imag__ x, scale);
|
||||
absx = __scalbnf (absx, scale);
|
||||
absy = __scalbnf (absy, scale);
|
||||
}
|
||||
|
||||
d = __ieee754_hypotf (__real__ x, __imag__ x);
|
||||
d = __ieee754_hypotf (absx, absy);
|
||||
|
||||
__real__ result = __ieee754_logf (d) - scale * (float) M_LN2;
|
||||
__imag__ result = __ieee754_atan2f (__imag__ x, __real__ x);
|
||||
|
Reference in New Issue
Block a user