(try 2) [4.3] making a few real functions work with dfp

Manuel López-Ibáñez lopezibanez@gmail.com
Thu Nov 30 01:02:00 GMT 2006

It seems you didn't like my patch. No problem, I have another. :-)

So again, this patch makes exact_real_truncate() and real_isinteger() handle dfp
values correctly.

In order to do so, it compares decimal floating point for equality in
value instead of bitwise identity. No normalisation is performed in
this patch. Still, I am not sure this is more correct that
normalising, since here NaN, infinite and signed zeroes are not
handled in the same way as with real_identical. But I have run out of
ideas, and without this I cannot implement support for dfp in the new
Wconversion option.

Bootstrapped and tested with --enable-languages=all
--enable-decimal-float for trunk revision 119259 on i686-pc-linux-gnu

2006-11-30   Manuel Lopez-Ibanez <manu@gcc.gnu.org>

   * real.c  (exact_real_truncate): Use REAL_VALUES_EQUAL to compare
decimal floating point values instead of real_identical since dfp
values are not normalised by design.
   (real_isinteger): Likewise.
-------------- next part --------------
Index: gcc/real.c
--- gcc/real.c	(revision 119259)
+++ gcc/real.c	(working copy)
@@ -2505,6 +2505,10 @@ exact_real_truncate (enum machine_mode m
   /* After conversion to the new mode, the value must be identical.  */
   real_convert (&t, mode, a);
+  if (a->decimal || t.decimal)
+    return REAL_VALUES_EQUAL(t, *a);
   return real_identical (&t, a);
@@ -4977,5 +4981,13 @@ real_isinteger (const REAL_VALUE_TYPE *c
   real_trunc (&cint, mode, c);
+  /* Trailing zeroes are significant in decimal float values. That is,
+     a decimal float value may be equal to an integer when truncated
+     but they don't need to be bitwise identical.  */
+  if (c->decimal)
+    return REAL_VALUES_EQUAL(*c, cint);
   return real_identical (c, &cint);

More information about the Gcc-patches mailing list