aboutsummaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2005-07-29 22:14:22 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2005-07-29 22:14:22 +0100
commitbc1594c1428a6202a739b157bcdd0f4db2c5faf7 (patch)
tree5016d5b89f3bdb36574cad26940fb18ba94a1653 /gcc/real.c
parent3aca4bff532e98480b7a9e9b41b9df608bd90fed (diff)
downloadgcc-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.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c
index 045a803..2d26185 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++;
}
}