While the C standard does not require this, it STRONGLY ADVISES that float
and double
are standard IEEE 754 single and double precision floating-point types, respectively. Which they are on any architecture that supports them in hardware (which means practically everywhere).
Things are slightly more tricky with long double
, as not many architectures support floating-point types of higher-than-double precision. The standard requires that long double
has at least as much range and precision as double
. Which means that if an architecture does not support anything more, long double
type is identical to double
. And even if it does (like x87), some compilers still make long double
equivalent to double
(like M$VC), while others expose the extended precision type as long double
(like Borland and GCC).
Even if the compiler exposes the extended precision type, there is still no standard on what exactly "extended-precision" means. On x87 this is 80-bit. Some other architectures have 128-bit quad-precision types. Even on x87 some compilers have sizeof(long double)
= 10, while others pad it for alignment, so that it is 12 or 16 (of 8 if long double
is double
).
So the bottom line is, implementation of long double
varies across platforms. The only thing you can be sure about it, is that it is at least equivalent to double
. If you want to write portable code, don't depend on its representation - keep it away from interfaces and binary I/O. Using long double
in internal calculations of your program is OK though.