This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
support of 128 bit long real on linux for ia32
- From: Winfrid Tschiedel <winfrid dot tschiedel at hpc dot fujitsu-siemens dot com>
- To: gcc-help at gcc dot gnu dot org
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 12 Feb 2002 09:11:37 +0100 (MET)
- Subject: support of 128 bit long real on linux for ia32
- Reply-to: Winfrid dot Tschiedel at hpc dot fujitsu-siemens dot com
Hello,
I have a small question concerning the support of
long double on linux ia32 with gcc v3.x
I am currently using gcc-3.0.1 on redhat 7.2, kernel 2.4.7-10smp
I tried this small program :
#include <stdio.h>
/*
icl -DTYP=float precision.c
icl -DTYP="long double" -Qlong_double -Qpc80 precision.c
*/
int same(TYP* t1, TYP* t2) { return *t1 == *t2; }
int same2(TYP* t1, TYP* t2) { return *t1 == *t2 / *t1; }
main()
{
int mbits = 0, ebits = 1;
TYP t = 1.0, delta = 0.5, tt = t + delta;
while ( !same( &t, &tt)) {
delta *= 0.5;
tt = t + delta;
mbits++;
}
printf( "mantissa precision: 1 + %3d = %3d bits\n", mbits, mbits+1);
t = 2.0; tt = t * t;
while ( same2( &t, &tt)) {
t *= t;
tt = t * t;
ebits++;
}
printf( "exponent precision: 1 + %3d = %3d bits\n", ebits, ebits+1);
printf( "-----------------------------------------------\n"
"total significant bits: %3d "
"(out of %3d)\n", 2 + mbits + ebits, sizeof( TYP) * 8);
}
and got the following results :
gcc -DTYP="long double" -m128bit-long-double precision.c -o prec_128
./prec_128
mantissa precision: 1 + 63 = 64 bits
exponent precision: 1 + 14 = 15 bits
-----------------------------------------------
total significant bits: 79 (out of 128)
gcc -DTYP="long double" -m96bit-long-double precision.c -o prec_96
./prec_96
mantissa precision: 1 + 63 = 64 bits
exponent precision: 1 + 14 = 15 bits
-----------------------------------------------
total significant bits: 79 (out of 96)
Now my question, is it true, that the precision for both compilations
is the same, except that for -m128bit-long-double the result of
sizeof(long double) is 16, while in the other case sizeof(long double) is 12?
Do plan to enhance your compiler in order to get
"long double" in C compatible with real(16) in fortran ?
program prec
real (kind=kind(1.e0_16)) , parameter :: one = 1.0
write ( unit=*,fmt=* ) huge(one)
write ( unit=*,fmt=* ) tiny(one)
write ( unit=*,fmt=* ) maxexponent(one)
write ( unit=*,fmt=* ) minexponent(one)
write ( unit=*,fmt=* ) precision(one)
write ( unit=*,fmt=* ) epsilon(one)
write ( unit=*,fmt="(z32)" ) one+epsilon(one)
end
ifc precision.F
ifc: NOTE: The evaluation period for this product ends on 15-may-2002 UTC.
program PREC
11 Lines Compiled
winfrid@dino csh 23: ./a.out
1.189731495357231765085759326628007Q+4932
3.362103143112093506262677817321753Q-4932
16384
-16381
33
1.925929944387235853055977942584928Q-0034
3FFF0000000000000000000000000001
Many thanks in advance for your information.
Take care,
Winfrid
--
_______________________________________________________________________________
Fujitsu Siemens Computers
OEA VC HPC Email: winfrid.tschiedel@hpc.fujitsu-siemens.com
Otto-Hahn-Ring 6 Tel. : ++49-89-636-45652
81739 Muenchen Fax : ++49-89-636-44088
MS Exchange : winfrid.tschiedel@fujitsu-siemens.com