Size of the real type

Anders F Björklund afb at algonet.se
Wed Mar 8 23:20:46 PST 2006


kinghajj wrote:

> This is just an FYI, but on my computer, this code:
> 
> import std.stdio;
> 
> int main(char[][] args)
> {
> writefln(real.sizeof * 8);
> return 0;
> }

Side note:
Who said the size of a "real" is 80 bits ? The size varies.
It's just defined as: "largest hardware implemented FP size"

I get 64, here on PowerPC :-) On a SPARC, you could get 128.

> Outputs the size of real as 96 bits, not 80.
> I have an Intel Pentium 4 (Prescott) CPU.

The difference is due to alignment of the long double type.

In x86 Linux, it is 96 bits. In x64 Linux, it is 128 bits...
But they both still only use 80 bits, just add some padding.

--anders

PS.
http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/i386-and-x86_002d64-Options.html
"The i386 application binary interface specifies the size to be 96 bits, 
so -m96bit-long-double is the default in 32 bit mode." [...] "In the 
x86-64 compiler, -m128bit-long-double is the default choice as its ABI 
specifies that long double is to be aligned on 16 byte boundary."



More information about the Digitalmars-d mailing list