diff options
Diffstat (limited to 'newlib/libm/common/s_lrint.c')
-rw-r--r-- | newlib/libm/common/s_lrint.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/newlib/libm/common/s_lrint.c b/newlib/libm/common/s_lrint.c index b37f50f..b37b93a 100644 --- a/newlib/libm/common/s_lrint.c +++ b/newlib/libm/common/s_lrint.c @@ -103,26 +103,17 @@ TWO52[2]={ if(j0 < 20) { /* j0 in [-1023,19] */ - if(j0 < -1) - return 0; - else - { - /* j0 in [0,19] */ - /* shift amt in [0,19] */ - w = TWO52[sx] + x; - t = w - TWO52[sx]; - GET_HIGH_WORD(i0, t); - /* Detect the all-zeros representation of plus and - minus zero, which fails the calculation below. */ - if ((i0 & ~(1L << 31)) == 0) - return 0; - /* After round: j0 in [0,20] */ - j0 = ((i0 & 0x7ff00000) >> 20) - 1023; - i0 &= 0x000fffff; - i0 |= 0x00100000; - /* shift amt in [20,0] */ - result = i0 >> (20 - j0); - } + w = TWO52[sx] + x; + t = w - TWO52[sx]; + GET_HIGH_WORD(i0, t); + /* Detect the all-zeros representation of plus and + minus zero, which fails the calculation below. */ + if ((i0 & ~(1L << 31)) == 0) + return 0; + j0 = ((i0 & 0x7ff00000) >> 20) - 1023; + i0 &= 0x000fffff; + i0 |= 0x00100000; + result = (j0 < 0 ? 0 : i0 >> (20 - j0)); } else if (j0 < (int)(8 * sizeof (long int)) - 1) { |