If the implementation supports any of the followingISO 60559 types as an extended floating-point type, then:
- the corresponding macro is defined as1 to indicate support,
- the correspondingfloating-point literal suffix is available, and
- the corresponding type alias name is provided:
Types Defined in header <stdfloat> | Literal suffix | Predefined macro | C language type | Type properties |
---|
bits of storage | bits of precision | bits of exponent | max exponent |
float16_t | f16 orF16 | __STDCPP_FLOAT16_T__ | _Float16 | 16 | 11 | 5 | 15 |
---|
float32_t | f32 orF32 | __STDCPP_FLOAT32_T__ | _Float32 | 32 | 24 | 8 | 127 |
---|
float64_t | f64 orF64 | __STDCPP_FLOAT64_T__ | _Float64 | 64 | 53 | 11 | 1023 |
---|
float128_t | f128 orF128 | __STDCPP_FLOAT128_T__ | _Float128 | 128 | 113 | 15 | 16383 |
---|
bfloat16_t | bf16 orBF16 | __STDCPP_BFLOAT16_T__ | (N/A) | 16 | 8 | 8 | 127 |
---|
The typestd::bfloat16_t
is known asBrain Floating-Point.
Unlike thefixed width integer types, which may be aliases tostandard integer types, the fixed width floating-point types must be aliases to extended floating-point types (notfloat /double /longdouble), therefore not drop-in replacements for standard floating-point types.
[edit]Example
#include <stdfloat> #if __STDCPP_FLOAT64_T__ != 1#error "64-bit float type required"#endif int main(){ std::float64_t f= 0.1f64;}
[edit]References
- C++23 standard (ISO/IEC 14882:2024):
- 6.8.3 Optional extended floating-point types [basic.extended.fp]
[edit]See also