diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-29 21:14:22 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-29 21:14:22 +0000 |
commit | a5bd524b0c4b5fd3d91bbbdd16baceafb07b11d3 (patch) | |
tree | 5016d5b89f3bdb36574cad26940fb18ba94a1653 /gcc | |
parent | a253fb3e9da4facc34310ab656d16f8582da0f79 (diff) | |
download | gcc-a5bd524b0c4b5fd3d91bbbdd16baceafb07b11d3.tar.gz |
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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102567 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/real.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/hex-round-1.c | 82 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/hex-round-2.c | 114 |
5 files changed, 212 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 980c4912e00..781ab8b9462 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-07-29 Joseph S. Myers <joseph@codesourcery.com> + + 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 ".". + 2005-07-29 David Edelsohn <edelsohn@gnu.org> * config/rs6000/altivec.md: Convert UNSPEC numerical values to 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++; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa60bc1a194..9516f68f83f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-07-29 Joseph S. Myers <joseph@codesourcery.com> + + PR c/21720 + * gcc.dg/hex-round-1.c: Test more cases. + * gcc.dg/hex-round-2.c: New test. + 2005-07-29 Diego Novillo <dnovillo@redhat.com> PR 22550 diff --git a/gcc/testsuite/gcc.dg/hex-round-1.c b/gcc/testsuite/gcc.dg/hex-round-1.c index 1ce9c35c0fa..3276ad46378 100644 --- a/gcc/testsuite/gcc.dg/hex-round-1.c +++ b/gcc/testsuite/gcc.dg/hex-round-1.c @@ -10,6 +10,64 @@ int main (void) { #if FLT_RADIX == 2 && FLT_MANT_DIG == 24 + if (0x1.0000011p0f == 1) + link_failure (); + if (0x1.00000101p0f == 1) + link_failure (); + if (0x1.000001001p0f == 1) + link_failure (); + if (0x1.0000010001p0f == 1) + link_failure (); + if (0x1.00000100001p0f == 1) + link_failure (); + if (0x1.000001000001p0f == 1) + link_failure (); + if (0x1.0000010000001p0f == 1) + link_failure (); + if (0x1.00000100000001p0f == 1) + link_failure (); + if (0x1.000001000000001p0f == 1) + link_failure (); + if (0x1.0000010000000001p0f == 1) + link_failure (); + if (0x1.00000100000000001p0f == 1) + link_failure (); + if (0x1.000001000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000001p0f == 1) + link_failure (); if (0x1.000001000000000000000000000000000001p0f == 1) link_failure (); if (0x1.0000010000000000000000000000000000001p0f == 1) @@ -26,6 +84,30 @@ main (void) link_failure (); if (0x1.0000010000000000000000000000000000000000001p0f == 1) link_failure (); + if (0x1.00000100000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000000000000001p0f == 1) + link_failure (); #endif return 0; } diff --git a/gcc/testsuite/gcc.dg/hex-round-2.c b/gcc/testsuite/gcc.dg/hex-round-2.c new file mode 100644 index 00000000000..ba9b8bf3d02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/hex-round-2.c @@ -0,0 +1,114 @@ +/* Test for hexadecimal float rounding: bug 21720. Test with no "." + in number. */ +/* { dg-do link } */ +/* { dg-options "-O -std=gnu99" } */ + +#include <float.h> + +extern void link_failure (void); + +int +main (void) +{ +#if FLT_RADIX == 2 && FLT_MANT_DIG == 24 + if (0x10000011p-28f == 1) + link_failure (); + if (0x100000101p-32f == 1) + link_failure (); + if (0x1000001001p-36f == 1) + link_failure (); + if (0x10000010001p-40f == 1) + link_failure (); + if (0x100000100001p-44f == 1) + link_failure (); + if (0x1000001000001p-48f == 1) + link_failure (); + if (0x10000010000001p-52f == 1) + link_failure (); + if (0x100000100000001p-56f == 1) + link_failure (); + if (0x1000001000000001p-60f == 1) + link_failure (); + if (0x10000010000000001p-64f == 1) + link_failure (); + if (0x100000100000000001p-68f == 1) + link_failure (); + if (0x1000001000000000001p-72f == 1) + link_failure (); + if (0x10000010000000000001p-76f == 1) + link_failure (); + if (0x100000100000000000001p-80f == 1) + link_failure (); + if (0x1000001000000000000001p-84f == 1) + link_failure (); + if (0x10000010000000000000001p-88f == 1) + link_failure (); + if (0x100000100000000000000001p-92f == 1) + link_failure (); + if (0x1000001000000000000000001p-96f == 1) + link_failure (); + if (0x10000010000000000000000001p-100f == 1) + link_failure (); + if (0x100000100000000000000000001p-104f == 1) + link_failure (); + if (0x1000001000000000000000000001p-108f == 1) + link_failure (); + if (0x10000010000000000000000000001p-112f == 1) + link_failure (); + if (0x100000100000000000000000000001p-116f == 1) + link_failure (); + if (0x1000001000000000000000000000001p-120f == 1) + link_failure (); + if (0x10000010000000000000000000000001p-124f == 1) + link_failure (); + if (0x100000100000000000000000000000001p-128f == 1) + link_failure (); + if (0x1000001000000000000000000000000001p-132f == 1) + link_failure (); + if (0x10000010000000000000000000000000001p-136f == 1) + link_failure (); + if (0x100000100000000000000000000000000001p-140f == 1) + link_failure (); + if (0x1000001000000000000000000000000000001p-144f == 1) + link_failure (); + if (0x10000010000000000000000000000000000001p-148f == 1) + link_failure (); + if (0x100000100000000000000000000000000000001p-152f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000001p-156f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000001p-160f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000001p-164f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000001p-168f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000001p-172f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000001p-176f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000001p-180f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000001p-184f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000000001p-188f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000000001p-192f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000000001p-196f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000000000001p-200f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000000000001p-204f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000000000001p-208f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000000000000001p-212f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000000000000001p-216f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000000000000001p-220f == 1) + link_failure (); +#endif + return 0; +} |