mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Fix catan, catanh spurious overflows (bug 15409).
This commit is contained in:
@ -61,27 +61,44 @@ __catan (__complex__ double x)
|
||||
}
|
||||
else
|
||||
{
|
||||
double r2, num, den, f;
|
||||
|
||||
r2 = __real__ x * __real__ x;
|
||||
|
||||
den = 1 - r2 - __imag__ x * __imag__ x;
|
||||
|
||||
__real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den);
|
||||
|
||||
num = __imag__ x + 1.0;
|
||||
num = r2 + num * num;
|
||||
|
||||
den = __imag__ x - 1.0;
|
||||
den = r2 + den * den;
|
||||
|
||||
f = num / den;
|
||||
if (f < 0.5)
|
||||
__imag__ res = 0.25 * __ieee754_log (f);
|
||||
if (fabs (__real__ x) >= 16.0 / DBL_EPSILON
|
||||
|| fabs (__imag__ x) >= 16.0 / DBL_EPSILON)
|
||||
{
|
||||
__real__ res = __copysign (M_PI_2, __real__ x);
|
||||
if (fabs (__real__ x) <= 1.0)
|
||||
__imag__ res = 1.0 / __imag__ x;
|
||||
else if (fabs (__imag__ x) <= 1.0)
|
||||
__imag__ res = __imag__ x / __real__ x / __real__ x;
|
||||
else
|
||||
{
|
||||
double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0);
|
||||
__imag__ res = __imag__ x / h / h / 4.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 4.0 * __imag__ x;
|
||||
__imag__ res = 0.25 * __log1p (num / den);
|
||||
double r2, num, den, f;
|
||||
|
||||
r2 = __real__ x * __real__ x;
|
||||
|
||||
den = 1 - r2 - __imag__ x * __imag__ x;
|
||||
|
||||
__real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den);
|
||||
|
||||
num = __imag__ x + 1.0;
|
||||
num = r2 + num * num;
|
||||
|
||||
den = __imag__ x - 1.0;
|
||||
den = r2 + den * den;
|
||||
|
||||
f = num / den;
|
||||
if (f < 0.5)
|
||||
__imag__ res = 0.25 * __ieee754_log (f);
|
||||
else
|
||||
{
|
||||
num = 4.0 * __imag__ x;
|
||||
__imag__ res = 0.25 * __log1p (num / den);
|
||||
}
|
||||
}
|
||||
|
||||
if (fabs (__real__ res) < DBL_MIN)
|
||||
|
Reference in New Issue
Block a user