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.
This commit is contained in:
Bruce Evans 2008-02-08 01:45:52 +00:00
parent aa7c7c47cf
commit fbe8fb4d7b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176102

View File

@ -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)