signbit() returns nonzero for negative arguments, but we shouldn't assume

that it always returns the same nonzero value.
This commit is contained in:
David Schultz 2010-12-06 00:02:49 +00:00
parent 4a09b0df94
commit cf37ce3724
6 changed files with 8 additions and 6 deletions

View File

@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$");
int
fpequal(long double x, long double y)
{
return ((x == y && signbit(x) == signbit(y)) || isnan(x) && isnan(y));
return ((x == y && !signbit(x) == !signbit(y)) || isnan(x) && isnan(y));
}
void

View File

@ -85,7 +85,8 @@ int
fpequal(long double x, long double y)
{
return ((x == y && signbit(x) == signbit(y)) || (isnan(x) && isnan(y)));
return ((x == y && !signbit(x) == !signbit(y))
|| (isnan(x) && isnan(y)));
}
static void

View File

@ -50,7 +50,8 @@ static inline int
fpequal(long double x, long double y)
{
return ((x == y && signbit(x) == signbit(y)) || (isnan(x) && isnan(y)));
return ((x == y && !signbit(x) == !signbit(y))
|| (isnan(x) && isnan(y)));
}
/*

View File

@ -118,7 +118,7 @@ fpequal(long double x, long double y, long double tol)
if (isnan(x) && isnan(y))
return (1);
if (signbit(x) != signbit(y))
if (!signbit(x) != !signbit(y))
return (0);
if (x == y)
return (1);

View File

@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$");
int
fpequal(long double x, long double y)
{
return ((x == y && signbit(x) == signbit(y)) || isnan(x) && isnan(y));
return ((x == y && !signbit(x) == !signbit(y)) || isnan(x) && isnan(y));
}
void

View File

@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$");
int
fpequal(long double x, long double y)
{
return ((x == y && signbit(x) == signbit(y)) || isnan(x) && isnan(y));
return ((x == y && !signbit(x) == !signbit(y)) || isnan(x) && isnan(y));
}
/*