Author Topic: Printing REAL 10 values with the gcc  (Read 4391 times)

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Printing REAL 10 values with the gcc
« on: April 07, 2013, 02:03:28 AM »
I've started a thread in the old UK forum which deals with printing REAL10 (long double) numbers. There isn't a problem with the gcc under the Linux operating system, but under Windows the compiler output is only garbage. My suspicion was that this has to do with the windows libc, because the gcc must use it and the MS compilers don't support this data type.

But that seems not quiet right: surprisingly enough, with g++ (the C++ compiler of the gnu compiler collection) isn't such a problem. It handles REAL10 values correctly. I could figure out that during studying some C++ sources in Geneva. I won't publish that sources, but I've written a small test program which illustrates the point.

The program is tested under Windows 7 and Windows 8 (64 bit).

Gunther
« Last Edit: April 07, 2013, 10:12:00 AM by Gunther »
Get your facts first, and then you can distort them.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Printing REAL 10 values with the gcc
« Reply #1 on: April 07, 2013, 10:25:33 AM »
Added is the C source LongC64.zip. For more explanation, please check also that thread. Here is the output:

Code: [Select]

Layout of data types:
=====================

Long Double (REAL10)    = 16 Bytes
Double (REAL8)          =  8 Bytes
Float (REAL4)           =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593

Press any key to continue ...

Gunther
Get your facts first, and then you can distort them.