1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Fix csqrt missing underflows (bug 18370).

The csqrt implementations in glibc can miss underflow exceptions when
the real or imaginary part of the result becomes tiny in the course of
scaling down (in particular, multiplication by 0.5) and that scaling
is exact although the relevant part of the mathematical result isn't.
This patch forces the exception in a similar way to previous fixes.

Tested for x86_64 and x86.

	[BZ #18370]
	* math/s_csqrt.c (__csqrt): Force underflow exception for results
	whose real or imaginary part has small absolute value.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
This commit is contained in:
Joseph Myers
2015-08-19 22:42:01 +00:00
parent b75d1cfce6
commit 948e12a238
8 changed files with 411 additions and 2 deletions

View File

@ -148,6 +148,17 @@ __csqrtl (__complex__ long double x)
s = __scalbnl (s, scale);
}
if (fabsl (r) < LDBL_MIN)
{
long double force_underflow = r * r;
math_force_eval (force_underflow);
}
if (fabsl (s) < LDBL_MIN)
{
long double force_underflow = s * s;
math_force_eval (force_underflow);
}
__real__ res = r;
__imag__ res = __copysignl (s, __imag__ x);
}