In C and related programming languages, <code>long double</code> refers to a floating-point data type that is often more precise than double precision though the language standard only requires it to be at least as precise as <code>double</code>. As with C's other floating-point types, it may not necessarily map to an IEEE format.
The <code>long double</code> type was present in the original 1989 C standard, but support was improved by the 1999 revision of the C standard, or C99, which extended the standard library to include functions operating on <code>long double</code> such as <code>sinl()</code> and <code>strtold()</code>.
Long double constants are floating-point constants suffixed with "L" or "l" (lower-case L), e.g., 0.3333333333333333333333333333333333L or 3.1415926535897932384626433832795029L for quadruple precision. Without a suffix, the evaluation depends on FLT_EVAL_METHOD.
On the x86 architecture, most C compilers implement <code>long double</code> as the 80-bit extended precision type supported by x86 hardware (generally stored as 12 or 16 bytes to maintain data structure alignment), as specified in the C99 / C11 standards (IEC 60559 floating-point arithmetic (Annex F)). An exception is Microsoft Visual C++ for x86 (starting at 32-bit versions), which makes <code>long double</code> a synonym for <code>double</code>. The Intel C++ compiler on Microsoft Windows supports extended precision, but requires the <code>/Qlong‑double</code> switch for <code>long double</code> to correspond to the hardware's extended precision format.
Compilers may also use <code>long double</code> for the (binary128). This is the case on HP-UX, Solaris/SPARC, MIPS with the 64-bit or n32 ABI, 64-bit ARM (AArch64) (on operating systems using the standard AAPCS calling conventions, such as Linux), and z/OS with FLOAT(IEEE). Most implementations are in software, but some processors have hardware support.
On some PowerPC systems, <code>long double</code> is implemented as a double-double arithmetic, where a <code>long double</code> value is regarded as the exact sum of two double-precision values, giving at least a 106-bit precision; with such a format, the <code>long double</code> type does not conform to the IEEE floating-point standard. Otherwise, <code>long double</code> is simply a synonym for <code>double</code> (double precision), e.g. on 32-bit ARM, 64-bit ARM (AArch64) (on Windows and macOS) and on 32-bit MIPS (old ABI, a.k.a. o32).
With the GNU C Compiler, <code>long double</code> is 80-bit extended precision on x86 processors regardless of the physical storage used for the type (which can be either 96 or 128 bits), On some other architectures, <code>long double</code> can be double-double (e.g. on PowerPC) or 128-bit quadruple precision (e.g. on SPARC). As of gcc 4.3, a quadruple precision is also supported on x86, but as the nonstandard type <code>__float128</code> rather than <code>long double</code>.
Although the x86 architecture, and specifically the x87 floating-point instructions on x86, supports 80-bit extended-precision operations, it is possible to configure the processor to automatically round operations to double (or even single) precision. Conversely, in extended-precision mode, extended precision may be used for intermediate compiler-generated calculations even when the final results are stored at a lower precision (i.e. FLT_EVAL_METHOD == 2). With gcc on Linux, 80-bit extended precision is the default; on several BSD operating systems (FreeBSD and OpenBSD), double-precision mode is the default, and <code>long double</code> operations are effectively reduced to double precision. (NetBSD 7.0 and later, however, defaults to 80-bit extended precision ). However, it is possible to override this within an individual program via the FLDCW "floating-point load control-word" instruction. On x86_64, the BSDs default to 80-bit extended precision. Microsoft Windows with Visual C++ also sets the processor in double-precision mode by default, but this can again be overridden within an individual program (e.g. by the <code>_controlfp_s</code> function in Visual C++). The Intel C++ Compiler for x86, on the other hand, enables extended-precision mode by default. On IA-32 OS X, <code>long double</code> is 80-bit extended precision.
In CORBA (from specification of 3.0, which uses "ANSI/IEEE Standard 754-1985" as its reference), "the long double data type represents an IEEE double-extended floating-point number, which has an exponent of at least 15 bits in length and a signed fraction of at least 64 bits", with GIOP/IIOP CDR, whose floating-point types "exactly follow the IEEE standard formats for floating point numbers", marshalling this as what seems to be IEEE 754-2008 binary128 a.k.a. quadruple precision without using that name.