From 4fa28da3c9c38d1bd9b235fa85b264caf475fe4c Mon Sep 17 00:00:00 2001 From: bde Date: Fri, 8 Feb 2008 01:45:52 +0000 Subject: Fix truncl() when the result should be -0.0L. When the result is +-0.0L, it must have the same sign as the arg in all rounding modes, but it was always +0.0L. --- lib/msun/src/s_truncl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/msun/src') diff --git a/lib/msun/src/s_truncl.c b/lib/msun/src/s_truncl.c index c475b90..173b9ff 100644 --- a/lib/msun/src/s_truncl.c +++ b/lib/msun/src/s_truncl.c @@ -37,6 +37,7 @@ static char rcsid[] = "$FreeBSD$"; #endif static const long double huge = 1.0e300; +static const float zero[] = { 0.0, -0.0 }; long double truncl(long double x) @@ -47,7 +48,7 @@ truncl(long double x) if (e < MANH_SIZE - 1) { if (e < 0) { /* raise inexact if x != 0 */ if (huge + x > 0.0) - u.e = 0.0; + u.e = zero[u.bits.sign]; } else { uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1); if (((u.bits.manh & m) | u.bits.manl) == 0) -- cgit v1.1