4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-21 00:07:36 +08:00

Fix modf/f for NaN input

For NaN input the modf/f procedures should return NaN instead of zero
with the sign of the input.
This commit is contained in:
Fabian Schriever 2020-03-18 14:18:20 +01:00 committed by Ken Brown
parent fa8465ff48
commit 1895f91f95
2 changed files with 2 additions and 0 deletions

View File

@ -100,6 +100,7 @@ static double one = 1.0;
} else if (j0>51) { /* no fraction part */
__uint32_t high;
*iptr = x*one;
if (__fpclassifyd(x) == FP_NAN) return x+x; /* x is NaN, return NaN */
GET_HIGH_WORD(high,x);
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
return x;

View File

@ -52,6 +52,7 @@ static float one = 1.0;
} else { /* no fraction part */
__uint32_t ix;
*iptr = x*one;
if (__fpclassifyf(x) == FP_NAN) return x+x; /* x is NaN, return NaN */
GET_FLOAT_WORD(ix,x);
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */
return x;