Skip to content

Commit 0760ee1

Browse files
bernhardmgrubersponce
authored andcommitted
Add a slide on extended floating-point types
Fixes: hsf-training#213
1 parent 8a5972d commit 0760ee1

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

talk/basicconcepts/coresyntax.tex

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
long long ll = 0LL; // min 64 bit
7474
unsigned long long l = 0ULL; // min 64 bit
7575

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
7878
long double ld = 1.23E34L // min 64 bit float
7979
\end{cppcode}
8080
\end{frame}
@@ -135,8 +135,8 @@
135135
double d = 0x4d2.4p3; // hexfloat, 0x4d2.1 * 2^3
136136
// = 1234.25 * 2^3 = 9874
137137

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
140140
3.14l, 3.14L, // long double
141141
\end{cppcode}
142142
\end{frame}
@@ -159,3 +159,28 @@
159159
std::uintptr_t i = reinterpret_cast<uintptr_t>(&s);
160160
\end{cppcode}
161161
\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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy