[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

_Decimal64 support



       Hello,

you might be interested to know that gcc-4.2 will implement as an extension
(--enable-decimal-float) the 754R decimal formats. I was able to compile
the gcc-4.2-20061031 snapshot, and run my very first C program using decimal
floating-point numbers:

   #include <stdio.h>

   int
   main ()
   {
     _Decimal64 A, B, one, zero, two;

     zero = 0.0;
     one = 1.0;
     two = 2.0;

     A = one;
     B = one;
     while (((A + one) - A) - one == zero)
       A = two * A;
     while (((A + B) - A) - B != zero)
       B = B + one;

     printf ("radix is %u\n", (unsigned) B);

     return 0;
   }

   mermoz% /tmp/install/bin/gcc d64.c
   mermoz% ./a.out 
   radix is 10

(Just replace _Decimal64 by double and you will get 2 instead of 10.)

Paul Zimmermann

754 | revision | FAQ | references | list archive