Namespaces
Variants
Actions

Fixed width floating-point types (since C++23)

From cppreference.com
< cpp‎ | types
 
 
 
Type support
Basic types
Fixed width integer types(C++11)
Fixed width floating-point types(C++23)
(C++11)    
(C++17)
Numeric limits
C numeric limits interface
Runtime type information
 

If the implementation supports any of the following ISO 60559 types as an extended floating-point type, then:

  • the corresponding macro is defined as 1 to indicate support,
  • the corresponding floating-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_tf16 or F16__STDCPP_FLOAT16_T___Float1616 11 5 15
float32_tf32 or F32__STDCPP_FLOAT32_T___Float3232 24 8 127
float64_tf64 or F64__STDCPP_FLOAT64_T___Float6464 53 11 1023
float128_tf128 or F128__STDCPP_FLOAT128_T___Float128128 113 15 16383
bfloat16_tbf16 or BF16__STDCPP_BFLOAT16_T__(N/A) 16 8 8 127

Contents

[edit]Notes

The type std::bfloat16_t is known as Brain Floating-Point.

Unlike the fixed width integer types, which may be aliases to standard integer types, the fixed width floating-point types must be aliases to extended floating-point types (not float / 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

close