From bc1594c1428a6202a739b157bcdd0f4db2c5faf7 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 29 Jul 2005 22:14:22 +0100 Subject: 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 --- gcc/real.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/real.c') 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++; } } -- cgit v1.1