Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | types
Revision as of 06:14, 7 October 2022 by Cubbi (Talk | contribs)

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
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 types, the corresponding macro is predefined, floating-point literal suffix is available, and the typedef name is provided:

Type name
Defined in header <stdfloat>
Literal suffix Predefined macro C language type type properties
bits of storage bits of precision bits of exponent max exponent
std::float16_t f16 or F16 __STDCPP_­FLOAT16_­T__ _Float16 16 11 5 15
std::float32_t f32 or F32 __STDCPP_­FLOAT32_­T__ _Float32 32 24 8 127
std::float64_t f64 or F64 __STDCPP_­FLOAT64_­T__ _Float64 64 53 11 1023
std::float128_t f128 or F128 __STDCPP_­FLOAT64_­T__ _Float128 127 113 15 16383
std::bfloat16_t bf16 or BF16 __STDCPP_­BFLOAT16_­T__ (n/a) 16 8 8 127

Contents

Notes

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

Example

#include <stdfloat>
 
int main()
{
    std::float64_t f = 0.1f64;
}


References

  • C++23 standard (ISO/IEC 14882:2024):
  • 6.8.3 Optional extended floating-point types [basic.extended.fp]

See also