gnucobol-users
[Top][All Lists]
Advanced

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

[open-cobol-list] FW: _Decimal64 support


From: Bill Klein
Subject: [open-cobol-list] FW: _Decimal64 support
Date: Thu, 7 Dec 2006 15:43:53 -0600

Did this get distributed to the Open COBOL list?  If not, it might be of
interest.  (Especially in light of the "new" Floating-Point Standard
Arithmetic in the draft of the NEXT - 2009 or so - Standard) 

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Paul
Zimmermann
Sent: Tuesday, November 07, 2006 7:30 AM
To: address@hidden
Subject: _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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]