long double
C++ long double is guaranteed to be the largest built-in floating point data type. It has been introduced in C++11 standard and was intended to allow platforms to have a new, more precise data format, taking advantage of advances in computer architecture. It is, however, not a requirement that long double is more precise than double, just that it cannot be less precise.
It is not possible to enumerate long double values just like any other floating point format.
Literals
Numeric literals that are followed by by l or L are long double. For example: 1.5l
, .3L
, 5e-7l
, or 0L
.
long double can store positive infinity, negative infinity, and NaN (not a number). NaN is generated when the result is mathematically ambiguous or impossible to determine, for example 0÷0.
Characteristics
The <cfloat> library consists of the following constants describing the behaviour of float
- FLT_RADIX — base of the floating point numbers.
- LDBL_MANT_DIG — number of mantissa digits.
- LDBL_DIG — number of significant digits that can be stored.
- LDBL_MIN_EXP — minimum negative exponent.
- LDBL_MAX_EXP — maximum positive exponent.
- LDBL_MIN_10_EXP — minimum base-10 negative exponent that can be transformed into a valid long double
- LDBL_MAX_10_EXP — maximum base-10 positive exponent that can be transformed into a valid long double
- LDBL_EPSILON — the difference from 1.0 to the smallest possible value that is greater than 1.0
- LDBL_MIN — the smallest possible value that is greater than 0.0