diff options
author | Keith Packard via Newlib <newlib@sourceware.org> | 2020-03-26 03:18:20 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-03-26 14:21:33 +0300 |
commit | 3439f3b0e998fd59f4ed277bb0c05bf24d7dc831 (patch) | |
tree | 7fc36a74f6ae46f8923e2481ff0727fbcb478131 /newlib/libm/common/s_modf.c | |
parent | 61cd34c1bfab626c084fd4289657b8f1ac43a138 (diff) |
newlib/libm/common: Don't re-convert float to bits in modf/modff
These functions shared a pattern of re-converting the argument to bits
when returning +/-0. Skip that as the initial conversion still has the
sign bit.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'newlib/libm/common/s_modf.c')
-rw-r--r-- | newlib/libm/common/s_modf.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/newlib/libm/common/s_modf.c b/newlib/libm/common/s_modf.c index c826580b4..e552a9460 100644 --- a/newlib/libm/common/s_modf.c +++ b/newlib/libm/common/s_modf.c @@ -81,10 +81,8 @@ QUICKREF } else { i = (0x000fffff)>>j0; if(((i0&i)|i1)==0) { /* x is integral */ - __uint32_t high; *iptr = x; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { INSERT_WORDS(*iptr,i0&(~i),0); @@ -92,19 +90,15 @@ QUICKREF } } } else if (j0>51) { /* no fraction part */ - __uint32_t high; *iptr = x; if (__fpclassifyd(x) == FP_NAN) return *iptr = x+x; /* x is NaN, return NaN */ - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { /* fraction part in low x */ i = ((__uint32_t)(0xffffffff))>>(j0-20); if((i1&i)==0) { /* x is integral */ - __uint32_t high; *iptr = x; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { INSERT_WORDS(*iptr,i0,i1&(~i)); |