Files
2025-10-25 03:02:53 +03:00

103 lines
5.8 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[basic.extended.fp]
# 6 Basics [[basic]](./#basic)
## 6.9 Types [[basic.types]](basic.types#basic.extended.fp)
### 6.9.3 Optional extended floating-point types [basic.extended.fp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5705)
If the implementation supports an extended floating-point type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))
whose properties are specified by
the ISO/IEC 60559 floating-point interchange format binary16,
then the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") std::float16_t is declared in the header [<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") and names such a type,
the macro __STDCPP_FLOAT16_T__ is defined ([[cpp.predefined]](cpp.predefined "15.12Predefined macro names")), and
the floating-point literal suffixes f16 and F16 are supported ([[lex.fcon]](lex.fcon "5.13.4Floating-point literals"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5715)
If the implementation supports an extended floating-point type
whose properties are specified by
the ISO/IEC 60559 floating-point interchange format binary32,
then the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") std::float32_t is declared in the header [<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") and names such a type,
the macro __STDCPP_FLOAT32_T__ is defined, and
the floating-point literal suffixes f32 and F32 are supported[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5724)
If the implementation supports an extended floating-point type
whose properties are specified by
the ISO/IEC 60559 floating-point interchange format binary64,
then the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") std::float64_t is declared in the header [<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") and names such a type,
the macro __STDCPP_FLOAT64_T__ is defined, and
the floating-point literal suffixes f64 and F64 are supported[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5733)
If the implementation supports an extended floating-point type
whose properties are specified by
the ISO/IEC 60559 floating-point interchange format binary128,
then the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") std::float128_t is declared in the header [<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") and names such a type,
the macro __STDCPP_FLOAT128_T__ is defined, and
the floating-point literal suffixes f128 and F128 are supported[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5742)
If the implementation supports an extended floating-point type
with the properties, as specified by ISO/IEC 60559, of
radix (b) of 2,
storage width in bits (k) of 16,
precision in bits (p) of 8,
maximum exponent (emax) of 127, and
exponent field width in bits (w) of 8, then
the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") std::bfloat16_t is declared in the header [<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") and names such a type,
the macro __STDCPP_BFLOAT16_T__ is defined, and
the floating-point literal suffixes bf16 and BF16 are supported[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5755)
[*Note [1](#note-1)*:
A summary of the parameters for each type is given in Table [15](#tab:basic.extended.fp "Table 15: Properties of named extended floating-point types")[.](#6.sentence-1)
The precision p includes the implicit 1 bit at the beginning of the significand,
so the storage used for the significand is p−1 bits[.](#6.sentence-2)
ISO/IEC 60559 does not assign a name for a type
having the parameters specified for std::bfloat16_t[.](#6.sentence-3)
— *end note*]
Table [15](#tab:basic.extended.fp) — Properties of named extended floating-point types [[tab:basic.extended.fp]](./tab:basic.extended.fp)
| [🔗](#tab:basic.extended.fp-row-1)<br>**Parameter** | **float16_t** | **float32_t** | **float64_t** | **float128_t** | **bfloat16_t** |
| --- | --- | --- | --- | --- | --- |
| [🔗](#tab:basic.extended.fp-row-2)<br>ISO/IEC 60559 name | binary16 | binary32 | binary64 | binary128 | |
| [🔗](#tab:basic.extended.fp-row-3)<br>k, storage width in bits | 16 | 32 | 64 | 128 | 16 |
| [🔗](#tab:basic.extended.fp-row-4)<br>p, precision in bits | 11 | 24 | 53 | 113 | 8 |
| [🔗](#tab:basic.extended.fp-row-5)<br>emax, maximum exponent | 15 | 127 | 1023 | 16383 | 127 |
| [🔗](#tab:basic.extended.fp-row-6)<br>w, exponent field width in bits | 5 | 8 | 11 | 15 | 8 |
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5777)
*Recommended practice*: Any names that the implementation provides for
the extended floating-point types described in this subsection
that are in addition to the names declared in the [<stdfloat>](stdfloat.syn#header:%3cstdfloat%3e "17.4.2Header <stdfloat> synopsis[stdfloat.syn]") header
should be chosen to increase compatibility and interoperability
with the interchange types_Float16, _Float32, _Float64, and _Float128 defined in ISO/IEC TS 18661-3 and with future versions of ISO/IEC 9899[.](#7.sentence-1)