mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Improve clog, clog10 handling of values with real or imaginary part 1 (bug 13629).
This commit is contained in:
@ -41,21 +41,21 @@ __clogf (__complex__ float x)
|
||||
{
|
||||
/* Neither real nor imaginary part is NaN. */
|
||||
float absx = fabsf (__real__ x), absy = fabsf (__imag__ x);
|
||||
float d;
|
||||
int scale = 0;
|
||||
|
||||
if (absx < absy)
|
||||
{
|
||||
float t = absx;
|
||||
absx = absy;
|
||||
absy = t;
|
||||
}
|
||||
|
||||
if (absx > FLT_MAX / 2.0f)
|
||||
{
|
||||
scale = -1;
|
||||
absx = __scalbnf (absx, scale);
|
||||
absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f);
|
||||
}
|
||||
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;
|
||||
@ -63,9 +63,27 @@ __clogf (__complex__ float x)
|
||||
absy = __scalbnf (absy, scale);
|
||||
}
|
||||
|
||||
d = __ieee754_hypotf (absx, absy);
|
||||
if (absx == 1.0f && scale == 0)
|
||||
{
|
||||
float absy2 = absy * absy;
|
||||
if (absy2 <= FLT_MIN * 2.0f)
|
||||
{
|
||||
#if __FLT_EVAL_METHOD__ == 0
|
||||
__real__ result = absy2 / 2.0f - absy2 * absy2 / 4.0f;
|
||||
#else
|
||||
volatile float force_underflow = absy2 * absy2 / 4.0f;
|
||||
__real__ result = absy2 / 2.0f - force_underflow;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
__real__ result = __log1pf (absy2) / 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float d = __ieee754_hypotf (absx, absy);
|
||||
__real__ result = __ieee754_logf (d) - scale * (float) M_LN2;
|
||||
}
|
||||
|
||||
__real__ result = __ieee754_logf (d) - scale * (float) M_LN2;
|
||||
__imag__ result = __ieee754_atan2f (__imag__ x, __real__ x);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user