|
73 | 73 | long long ll = 0LL; // min 64 bit
|
74 | 74 | unsigned long long l = 0ULL; // min 64 bit
|
75 | 75 |
|
76 |
| - float f = 1.23f; // 32 (23+8+1) bit float |
77 |
| - double d = 1.23E34; // 64 (52+11+1) bit float |
| 76 | + float f = 1.23f; // 32 (1+8+23) bit float |
| 77 | + double d = 1.23E34; // 64 (1+11+52) bit float |
78 | 78 | long double ld = 1.23E34L // min 64 bit float
|
79 | 79 | \end{cppcode}
|
80 | 80 | \end{frame}
|
|
135 | 135 | double d = 0x4d2.4p3; // hexfloat, 0x4d2.1 * 2^3
|
136 | 136 | // = 1234.25 * 2^3 = 9874
|
137 | 137 |
|
138 |
| - 3.14f, 3.14F, 3.14f32, 3.14F32 // float (C++23 for f32) |
139 |
| - 3.14, 3.14, 3.14f64, 3.14F64 // double (C++23 for f64) |
| 138 | + 3.14f, 3.14F, // float |
| 139 | + 3.14, 3.14, // double |
140 | 140 | 3.14l, 3.14L, // long double
|
141 | 141 | \end{cppcode}
|
142 | 142 | \end{frame}
|
|
159 | 159 | std::uintptr_t i = reinterpret_cast<uintptr_t>(&s);
|
160 | 160 | \end{cppcode}
|
161 | 161 | \end{frame}
|
| 162 | + |
| 163 | +\begin{advanced} |
| 164 | +\begin{frame}[fragile] |
| 165 | + \frametitlecpp[23]{Extended floating-point types} |
| 166 | + \begin{block}{Extended floating-point types} |
| 167 | + \begin{itemize} |
| 168 | + \item \emph{Optional} types, which may be provided |
| 169 | + \item Custom conversion and promotion rules |
| 170 | + \end{itemize} |
| 171 | + \end{block} |
| 172 | + \begin{cppcode*}{gobble=4} |
| 173 | + #include <stdfloat> // may define these: |
| 174 | + |
| 175 | + std::float16_t = 3.14f16; // 16 (1+5+10) bit float |
| 176 | + std::float32_t = 3.14f32; // like float |
| 177 | + // but different type |
| 178 | + std::float64_t = 3.14f64; // like double |
| 179 | + // but different type |
| 180 | + std::float128_t = 3.14f128; // 128 (1+15+112) bit float |
| 181 | + std::bfloat_t = 3.14bf16; // 16 (1+8+7) bit float |
| 182 | + |
| 183 | + // also F16, F32, F64, F128 or BF16 suffix possible |
| 184 | + \end{cppcode*} |
| 185 | +\end{frame} |
| 186 | +\end{advanced} |
0 commit comments