While the C standard does not require this, it STRONGLY WARNS that float and double are standard IEEE 754 single and double precision floating point types, respectively. That they are located on any architecture that supports them in hardware (which means almost everywhere).
Something a bit more complicated with long double , since not many architectures support floating point types with higher precision. The standard requires that a long double have at least a range and precision like double . This means that if the architecture does not support anything else, the type long double is identical to double . And even if it does (e.g. x87), some compilers still make long double equivalent to double (e.g. M $ VC), while others display an extended precision type like long double (e.g. Borland and GCC).
Even if the compiler provides an extended type of precision, there is still no standard for what βextended precisionβ means. On x87 it is 80-bit. Some other architectures have 128-bit four-point types. Even on x87, some compilers have sizeof(long double) = 10, while others use it to align, so it's 12 or 16 (out of 8 if long double is double ).
So, the bottom line, the implementation of long double varies across platforms. The only thing you can be sure of is that it is at least equivalent to double . If you want to write portable code, not depend on its presentation - keep it away from interfaces and binary I / O. Using a long double in your program's internal calculations is fine, though.
source share