diff options
author | Joseph Myers <joseph@codesourcery.com> | 2005-07-29 21:14:22 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2005-07-29 21:14:22 +0000 |
commit | 03e672240efc4aed9588c9c5c23ea1758e7215cd (patch) | |
tree | 5016d5b89f3bdb36574cad26940fb18ba94a1653 /gcc/real.c | |
parent | 92364047cb6ad64a4626791ecf064152f2f37750 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@102567 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c index 045a803a594..2d261852106 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -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++; } } |