diff options
author | Joseph Myers <joseph@codesourcery.com> | 2005-07-29 22:14:22 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2005-07-29 22:14:22 +0100 |
commit | bc1594c1428a6202a739b157bcdd0f4db2c5faf7 (patch) | |
tree | 5016d5b89f3bdb36574cad26940fb18ba94a1653 /gcc/real.c | |
parent | 3aca4bff532e98480b7a9e9b41b9df608bd90fed (diff) | |
download | gcc-bc1594c1428a6202a739b157bcdd0f4db2c5faf7.zip gcc-bc1594c1428a6202a739b157bcdd0f4db2c5faf7.tar.gz gcc-bc1594c1428a6202a739b157bcdd0f4db2c5faf7.tar.bz2 |
re PR middle-end/21720 (GCC incorrectly rounds hex floats)
PR c/21720
* real.c (real_from_string): Also set last bit if there is a
nonzero hex digit beyond GCC's internal precision after ".".
testsuite:
* gcc.dg/hex-round-1.c: Test more cases.
* gcc.dg/hex-round-2.c: New test.
From-SVN: r102567
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -1815,6 +1815,10 @@ real_from_string (REAL_VALUE_TYPE *r, const char *str) |= (unsigned long) d << (pos % HOST_BITS_PER_LONG); pos -= 4; } + else if (d) + /* Ensure correct rounding by setting last bit if there is + a subsequent nonzero digit. */ + r->sig[0] |= 1; str++; } } |