03 / 32 · Foundations
Floating-point numbers
How computers approximate real numbers: the IEEE 754 formats and decoding a float bit by bit, rounding and machine epsilon, why 0.1 plus 0.2 is not 0.3, order-dependent sums, special values, narrow machine-learning formats and RISC-V floating-point instructions.
On this page 10
The previous note represented integers exactly: 32 bits hold every integer from about to , spaced 1 apart. Science and engineering need something else: numbers as small as and as large as , with a few significant digits each, and fractions such as . This note builds the representation every processor uses for them, the IEEE 754 floating-point formats: how a float is laid out in bits, how to decode one by hand, how results are rounded and how large the error can be, why familiar laws of arithmetic fail, what the special values mean, the narrow formats that machine learning runs on, and the RISC-V instructions that operate on floats.
Notation. A floating-point number is with sign bit , significand and exponent . In the stored format, is the exponent field read as an unsigned integer, the fraction field, the constant subtracted from , and the precision: the number of significand bits including the hidden one ( for single, for double). is rounded to the nearest representable number, the gap between neighbouring representable numbers around , the machine epsilon and the unit roundoff.
Baseline: fixed point#
The simplest way to store fractions is to keep integers and agree on a scale. In the Q16.16 fixed-point format a 32-bit two’s complement integer stands for : 16 bits before the binary point and 16 after. Addition and subtraction are plain integer instructions, and the spacing is everywhere.
Worked example. becomes , which stands for , an error of 0.006 %. The largest value is .
It breaks at both ends of the scale. The absolute error is fixed, so the relative error grows as numbers shrink: is stored as , 53 % too large, and anything below becomes 0. And the range stops at 32,768, so a product of two moderate numbers overflows. Fixed point survives where the range is known in advance, in signal processing and in the integer codes of quantized neural networks; for general computation the scale has to travel with the number.
Scientific notation in base 2#
Any nonzero real number can be written as with : shift the binary point until exactly one 1 stands before it. This is the normalized form. For example
The last line has no end: has an infinite binary expansion, just as has an infinite decimal one, because 10 has the prime factor 5 and 2 does not. A float keeps only the first significant bits, so is never stored exactly.
Since the leading bit of a normalized significand is always 1, it need not be stored. This hidden bit gives one extra bit of precision for free.
The IEEE 754 formats#
The IEEE 754 standard, first published in 1985 and revised in 2008 and 2019, fixed the layout and the arithmetic so that the same program gives the same results on every conforming machine (IEEE 754-2019). A binary format has three fields, from the most significant bit:
| Format | Sign | Exponent field | Fraction field | Bias | Precision |
|---|---|---|---|---|---|
single (float, binary32) | 1 | 8 bits | 23 bits | 127 | 24 |
double (double, binary64) | 1 | 11 bits | 52 bits | 1023 | 53 |
For an exponent field strictly between all zeros and all ones, the value is
The two extreme values of are reserved for zero, subnormal numbers, infinities and NaN, described below. The exponent is stored with a bias rather than in two’s complement so that the fields, read as one unsigned integer, are ordered like the values: for two positive floats, the one with the larger bit pattern is the larger number, and an integer comparator can sort them.
The range follows from the extreme exponents, and for single precision:
| Single | Double | |
|---|---|---|
| smallest positive normal | ||
| largest finite | ||
| machine epsilon | ||
| decimal digits, about | 7 | 16 |
Decoding a float bit by bit#
The single-precision float −12.5, bit by bit
Worked example. The single-precision pattern 0xC1480000:
- Write out the bits:
1 10000010 10010000000000000000000. The sign bit is 1, so the number is negative. - The exponent field is , so .
- The fraction field starts and is zero after that; with the hidden bit, the significand is .
- The value is .
Encoding runs the same steps backwards: gives , , and the bits after the binary point, padded with zeros to 23 bits. For , and the fraction is the repeating pattern cut to 23 bits and rounded, 0x3DCCCCCD. That float equals exactly ; the nearest double to is , closer but still not .
Rounding, ulp and machine epsilon#
Between two neighbouring powers of two, , a format with precision has equally spaced numbers. The spacing is
the value of one unit in the last place. The spacing doubles at every power of two: the representable numbers are dense near zero and sparse far from it, while the relative spacing stays between and . The machine epsilon is the gap between 1 and the next float.
Floating-point numbers on the line: the gaps double
Every arithmetic operation in IEEE 754 is correctly rounded: the result is the exact mathematical result rounded to a representable number, as if computed with infinite precision first. The default rule is round to nearest, ties to even: take the nearest representable number, and when the exact result lies exactly halfway between two, take the one whose last significand bit is 0. Ties to even rather than ties away from zero because it rounds up and down equally often on average, so sums of many rounded values do not drift. The other modes round toward zero, toward and toward ; interval arithmetic uses the last two to bound a result from both sides.
How large is the error? Let , inside the normal range. The neighbours of are apart, so
Every operation therefore satisfies with : about for single and for double. This one inequality is the starting point of all rounding-error analysis (Goldberg, 1991; Higham, 2002, §2.2).
Worked example. Above single-precision numbers are 2 apart, because . The integer lies exactly halfway between and . Their significands end in 0 and in 1 respectively, so ties to even gives . The next tie, , lies between (significand ending in 1) and (ending in 0) and rounds up to . A float counter therefore stops at : adding 1 gives a tie, which rounds back down.
Why 0.1 + 0.2 is not 0.3#
In double precision, 0.1 + 0.2 == 0.3 is false. Three roundings explain it, and the last one is a tie.
0.1is stored as , slightly too large.0.2is stored as , slightly too large, exactly twice the stored0.1.- Their exact sum is . In doubles are apart, and the sum lies exactly halfway between the two neighbours and : it equals , an odd multiple of half a gap. Ties go to the even significand, which is the upper neighbour. The result is .
- The literal
0.3is stored as the lower neighbour, , the double nearest to . The two differ by one ulp.
Nothing went wrong: each step was the best possible rounding. The decimal inputs were simply never representable. In single precision the same sum happens to round to the same float as 0.3f, so 0.1f + 0.2f == 0.3f is true; that is luck of the bit patterns, not a property of floats. The lesson is to compare computed floats with a tolerance relative to their size, as Python’s math.isclose does, never with ==, and to use integers (cents, not dollars) or decimal arithmetic for money.
Order matters: floating-point addition is not associative#
Rounding happens after every operation, so the grouping of a sum changes its result:
because rounds back to : near , doubles are apart.
Worked example (summation order). Sum for in single precision (C on an Apple M1, clang -O0; IEEE arithmetic gives these digits on any conforming machine):
| Order | Result |
|---|---|
| largest terms first, | 15.4036827 |
| smallest terms first, | 16.6860313 |
| largest first with Kahan’s compensation | 16.6953106 |
| double precision, for reference | 16.6953114 |
The forward sum is wrong in the second digit. Once the running sum passes 8, single-precision numbers are apart, and any term below half of that, , is rounded away entirely. The terms reach at ; that term is an exact tie, which rounds back to the running sum because its significand is even, and from there on the sum stays at 15.4036827: the remaining eight million terms change nothing. Adding the small terms first lets them accumulate into something large enough to survive. Kahan summation keeps a second float with the low-order part lost at each addition and feeds it back into the next one, and gets within one ulp of the correctly rounded result without sorting (Higham, 2002, §4.3).
Non-associativity has consequences beyond accuracy. A compiler may not reorder floating-point operations unless told it may (-ffast-math), because reordering changes results. A parallel sum split across threads or GPU blocks adds in a different order from a sequential one and gives slightly different answers, and different numbers of threads give different answers again. That is why the tiled attention of FlashAttention matches a standard implementation only up to rounding (NLP course).
Special values#
The reserved exponent fields encode values that keep a computation going when it leaves the normal range:
| Exponent field | Fraction | Meaning |
|---|---|---|
| all zeros | zero | |
| all zeros | nonzero | subnormal: |
| neither all zeros nor all ones | any | normal: |
| all ones | zero | |
| all ones | nonzero | NaN, “not a number” |
- Signed zero. and compare equal, but and . The sign records from which side a result underflowed to zero.
- Infinities come from overflow ( in single precision) and from division of a nonzero number by zero. They obey the expected rules: , .
- NaN is the result of an operation with no meaningful value: , , . Any arithmetic with a NaN gives NaN, so an error propagates to the output instead of being silently replaced. A NaN compares unequal to everything, including itself:
x != xis the classic test for NaN. - Subnormal numbers fill the gap between 0 and the smallest normal number . With the hidden bit becomes 0 and the exponent stays at , so subnormals are evenly spaced with the same gap as the lowest normal binade, down to the smallest positive single, . Without them, the difference of two distinct small numbers could round to zero; with them, holds only when . This is gradual underflow: precision fades bit by bit near zero instead of vanishing at once. Some processors handle subnormals in slow microcode, and many offer a “flush to zero” mode that trades this guarantee for speed.
Invalid operations, division by zero, overflow, underflow and inexact results also set exception flags that a program can test. By default they do not interrupt the program; RISC-V, as the standard allows, does not trap on them at all.
Narrow formats for machine learning#
Neural networks tolerate low precision, and halving the bits of every number halves memory and memory traffic and multiplies the throughput of matrix units. Three narrow formats dominate:
| Format | Sign, exponent, fraction | Bias | Largest finite | Smallest normal | |
|---|---|---|---|---|---|
| fp16 (binary16) | 1, 5, 10 | 15 | 65,504 | ||
| bf16 (bfloat16) | 1, 8, 7 | 127 | |||
| fp8 E4M3 | 1, 4, 3 | 7 | 448 | ||
| fp8 E5M2 | 1, 5, 2 | 15 | 57,344 |
- fp16 is the IEEE half-precision format. Its range is narrow: gradients smaller than about , the smallest subnormal, become zero, so mixed-precision training multiplies the loss by a scale factor before the backward pass and divides it out afterwards (Micikevicius et al., 2018).
- bf16 keeps the 8-bit exponent of single precision and cuts the fraction to 7 bits: it is the top half of a float32. Conversion is a rounding of the low 16 bits, the range is that of float32, and no loss scaling is needed. Precision is low, about 2–3 decimal digits, but training is insensitive to it (Kalamkar et al., 2019). Google introduced the format for its TPUs.
- fp8 comes in two variants (Micikevicius et al., 2022). E4M3 has more precision and is used for weights and activations; it gives up infinities and keeps a single NaN pattern per sign to extend its range to 448. E5M2 follows the IEEE conventions and its wider range suits gradients.
Worked example. in fp16 is 0x2E66 , and in bf16 0x3DCD : the upper 16 bits of the float32 0x3DCCCCCD, rounded up because the discarded half 0xCCCD is more than half of 0x10000. The relative errors are and , within each format’s . Values above 65,504 overflow fp16 but fit easily in bf16.
Below 8 bits, the quantization note of the NLP course switches from floating point to integer codes with a scale, the fixed-point idea of the baseline applied per block of weights.
Floating point in RISC-V#
Floating point is an optional extension of RISC-V: F for single precision and D for double (RISC-V Unprivileged ISA, F and D chapters). Both follow IEEE 754.
- Registers. 32 floating-point registers
f0–f31, separate from the integer registers, each FLEN bits wide (32 with F, 64 with D). A single-precision value in a 64-bit register is NaN-boxed: the upper 32 bits are all ones. The calling convention names them like the integer registers:ft0–ft11temporaries,fs0–fs11saved,fa0–fa7arguments and results. - Loads and stores move bits unchanged:
flw/fswandfld/fsd. - Arithmetic:
fadd.s,fsub.s,fmul.s,fdiv.s,fsqrt.s,fmin.s,fmax.s, and the.dforms for double. The fused multiply-addfmadd.s rd, rs1, rs2, rs3computes with a single rounding, more accurate than a multiply followed by an add. - Comparisons
feq.s,flt.s,fle.swrite 0 or 1 into an integer register, and an ordinary branch then tests it. Comparisons with a NaN give 0. - Conversions:
fcvt.w.s(float to signed integer),fcvt.s.w(integer to float),fcvt.s.dandfcvt.d.sbetween precisions.fmv.x.wandfmv.w.xcopy the 32 bits between an integer and a floating-point register without converting. - Control and status. The
fcsrregister holds the rounding modefrm(round to nearest even by default; also toward zero, down, up, and nearest with ties away from zero) and the accrued exception flagsfflags: invalid (NV), divide by zero (DZ), overflow (OF), underflow (UF), inexact (NX). Each arithmetic instruction can also name its own rounding mode.
Floating-point arithmetic is slower than integer arithmetic. An addition must align the binary points of its operands by shifting the significand of the one with the smaller exponent, add, renormalize and round, so floating-point units take several cycles per operation and are pipelined (Patterson and Hennessy, 2020, §3.5).
What changed#
| Fixed point Q16.16 (baseline) | Single-precision float | |
|---|---|---|
| Bits | 32 | 32 |
| Range | about | about |
| Smallest positive | ||
| Error | absolute, at most | relative, at most for normal numbers |
| Spacing | constant | doubles at each power of two |
| Hardware | the integer ALU | a separate floating-point unit, several cycles per operation |
| Laws of arithmetic | exact addition, associative (until overflow) | every operation rounds; not associative |
| Special values | none | , , NaN, subnormals |
Limitations#
- Every operation rounds. Errors accumulate, and subtracting two nearly equal numbers cancels their leading digits and leaves mostly rounding error (catastrophic cancellation); the conditioning note of the Mathematics course bounds the damage and shows how to rewrite formulas to avoid it. The bound holds per operation, not per program.
- Not associative, not distributive. Results depend on evaluation order, so parallel and sequential code, or two compilers, can disagree in the last bits.
- Decimal fractions are inexact. , and are approximations; money belongs in integers or decimal types.
- Integers are exact only up to . Above in single and in double, not every integer is representable.
- NaN breaks ordinary logic.
x == xis false for NaN, and sorting or taking a maximum with NaNs present needs care.
What you should remember#
- . Single: 1 + 8 + 23 bits, bias 127. Double: 1 + 11 + 52 bits, bias 1023. The leading 1 is hidden.
- Spacing doubles at every power of two; ; ( single, double).
- Operations are correctly rounded, by default to nearest with ties to even: , .
- in double because no decimal fraction among them is representable; compare floats with a relative tolerance.
- Floating-point addition is not associative: summing small terms first, or with Kahan’s compensation, is more accurate.
- Special encodings: gives zeros and subnormals, all ones gives infinities and NaN; NaN is unequal to itself.
- fp16 has a narrow range, bf16 has float32’s range with 8 significant bits, fp8 comes as E4M3 and E5M2.
- RISC-V F and D: separate registers
f0–f31,flw/fld,fadd.s/fadd.d, comparisons into integer registers,fcsrwith the rounding mode and exception flags.
Code#
A decoder for single-precision floats in Python. struct converts between a Python float (a double) and the bytes of a C float; everything else is shifts and masks:
import math
import struct
from decimal import Decimal
from fractions import Fraction
def bits32(x): # the 32 bits of x rounded to single precision
return struct.unpack('>I', struct.pack('>f', x))[0]
def fields32(x): # sign, exponent field, fraction field
b = bits32(x)
return b >> 31, (b >> 23) & 0xFF, b & 0x7FFFFF
def decode32(s, E, f): # the value, by the formulas of the note
if E == 255:
return math.nan if f else (-1) ** s * math.inf
if E == 0: # subnormal: no hidden 1, exponent fixed at -126
return (-1) ** s * (f / 2**23) * 2.0**-126
return (-1) ** s * (1 + f / 2**23) * 2.0**(E - 127)
for x in (-12.5, 0.1, 1.0, 2.0**-149, math.inf):
s, E, f = fields32(x)
print(f'{x!r:>8} {bits32(x):08X} s={s} E={E:3d} f={f:06X} -> {decode32(s, E, f)!r}')
# -12.5 C1480000 s=1 E=130 f=480000 -> -12.5
# 0.1 3DCCCCCD s=0 E=123 f=4CCCCD -> 0.10000000149011612
# 1.0 3F800000 s=0 E=127 f=000000 -> 1.0
# 1.401298464324817e-45 00000001 s=0 E= 0 f=000001 -> 1.401298464324817e-45
# inf 7F800000 s=0 E=255 f=000000 -> inf
print(Decimal(struct.unpack('>f', struct.pack('>f', 0.1))[0])) # 0.100000001490116119384765625: the float nearest 0.1
print(Decimal(0.1)) # 0.1000000000000000055511151231257827021181583404541015625: the double
# 0.1 + 0.2 in double: three roundings, and the last one is a tie
a, b = Fraction(0.1), Fraction(0.2)
exact = a + b # the exact sum of the two doubles
lo, hi = Fraction(0.3), Fraction(0.30000000000000004) # the two doubles around it
print(exact - lo == hi - exact, 0.1 + 0.2 == 0.30000000000000004, 0.1 + 0.2 == 0.3) # True True False
print(exact * 2**55, lo * 2**54, hi * 2**54) # 10808639105689191 5404319552844595 5404319552844596: the tie goes to the even neighbour
print(math.isclose(0.1 + 0.2, 0.3)) # True: compare with a relative tolerance
# rounding to nearest, ties to even, at 2^24 where float spacing becomes 2
f32 = lambda x: struct.unpack('>f', struct.pack('>f', x))[0]
print([int(f32(2**24 + k)) for k in range(5)]) # [16777216, 16777216, 16777218, 16777220, 16777220]
# machine epsilon: the gap between 1 and the next number
print(math.ulp(1.0) == 2.0**-52, f32(1 + 2.0**-23) > 1, f32(1 + 2.0**-24) == 1) # True True True
print(math.nextafter(1.0, 2) - 1, 2.0**-23) # 2.220446049250313e-16 1.1920928955078125e-07
# narrow formats: fp16 via struct's 'e' code; bf16 = the top 16 bits of a float32, rounded to nearest even
def bf16(x):
b = bits32(x)
b = (b + 0x7FFF + ((b >> 16) & 1)) >> 16 # round the low 16 bits away, ties to even
return b, struct.unpack('>f', struct.pack('>I', b << 16))[0]
h = struct.unpack('>H', struct.pack('>e', 0.1))[0]
print(f'{h:04X}', struct.unpack('>e', struct.pack('>e', 0.1))[0]) # 2E66 0.0999755859375
print(f'{bf16(0.1)[0]:04X}', bf16(0.1)[1]) # 3DCD 0.10009765625
print((2 - 2**-10) * 2**15, (2 - 2**-7) * 2**127) # 65504.0 3.3895313892515355e+38: largest fp16 and bf16
try:
struct.pack('>e', 70000.0)
except OverflowError as err:
print('fp16:', err) # fp16: float too large to pack with e format
# fixed point Q16.16, the baseline
q = round(0.1 * 2**16)
print(q, q / 2**16, (2**31 - 1) / 2**16, 2**-16) # 6554 0.100006103515625 32767.99998474121 1.52587890625e-05
Summation order and special values in C, compiled with clang -std=c17 -Wall -Wextra -O0. The sums are determined by IEEE 754 arithmetic; the spelling of nan and inf in the output is the C library’s (macOS here):
#include <float.h>
#include <math.h>
#include <stdio.h>
int main(void) {
/* the same sum of 1/k for k = 1..10^7, in three orders and two precisions */
int n = 10000000;
float fwd = 0.0f, bwd = 0.0f, kahan = 0.0f, c = 0.0f;
double ref = 0.0;
for (int k = 1; k <= n; k++) fwd += 1.0f / (float)k; /* largest terms first */
for (int k = n; k >= 1; k--) bwd += 1.0f / (float)k; /* smallest terms first */
for (int k = 1; k <= n; k++) { /* Kahan: carry the lost low part along */
float y = 1.0f / (float)k - c, t = kahan + y;
c = (t - kahan) - y;
kahan = t;
}
for (int k = n; k >= 1; k--) ref += 1.0 / k;
printf("%.7f %.7f %.7f %.7f\n", fwd, bwd, kahan, ref); /* 15.4036827 16.6860313 16.6953106 16.6953114 */
float s = 0.0f; int k = 1;
while (s + 1.0f / (float)k != s) s += 1.0f / (float)k++; /* when does the forward sum stop growing? */
printf("%d %.7f\n", k, s); /* 2097152 15.4036827: 1/2^21 is half a gap at 15.4 */
printf("%d %d\n", 0.1 + 0.2 == 0.3, 0.1f + 0.2f == 0.3f); /* 0 1: true in float, false in double */
printf("%g %g\n", (1e20 + -1e20) + 1.0, 1e20 + (-1e20 + 1.0)); /* 1 0: addition is not associative */
volatile double zero = 0.0; /* volatile: computed at run time */
double inf = 1.0 / zero, nan = zero / zero;
printf("%g %g %g %g\n", inf, -inf, nan, inf - inf); /* inf -inf nan nan */
printf("%d %d %d\n", nan == nan, 0.0 == -0.0, isnan(nan)); /* 0 1 1 */
printf("%g %g\n", 1.0 / zero, 1.0 / -zero); /* inf -inf: the sign of zero matters */
printf("%g %g %g\n", FLT_EPSILON, FLT_MIN, FLT_TRUE_MIN); /* 1.19209e-07 1.17549e-38 1.4013e-45 */
printf("%g %g\n", FLT_MAX, DBL_MAX); /* 3.40282e+38 1.79769e+308 */
printf("%g\n", FLT_MAX * 2.0f); /* inf: overflow */
return 0;
}
Taking a float apart needs only integer instructions, so it runs on RV32I (RARS syntax):
# Take the float -12.5 apart with integer instructions only
.data
x: .word 0xC1480000 # the bits of -12.5f
.text
main:
lw t0, x
srli a0, t0, 31 # sign: bit 31
li a7, 1
ecall # prints 1
li a0, 32
li a7, 11
ecall
srli a0, t0, 23 # exponent field: bits 30..23
andi a0, a0, 0xFF
addi a0, a0, -127 # remove the bias
li a7, 1
ecall # prints 3
li a0, 32
li a7, 11
ecall
li t1, 0x7FFFFF # fraction field: bits 22..0
and a0, t0, t1
li t1, 0x800000 # put back the hidden 1
or a0, a0, t1
li a7, 34
ecall # prints 0x00c80000: 1.1001 binary, scaled by 2^23
li a7, 10
ecall
The same sums with the F and D extensions. This excerpt is not run here; it runs in RARS (which implements RV32 with F and D, and whose system calls 2 and 3 print fa0 as a float and as a double):
# 0.1 + 0.2 in single and in double precision (RARS, RV32IMFD)
.data
f01: .float 0.1
f02: .float 0.2
f03: .float 0.3
.align 3 # doubles on an 8-byte boundary
d01: .double 0.1
d02: .double 0.2
.text
main:
la t0, f01
flw ft0, 0(t0) # ft0 = 0.1f
flw ft1, 4(t0) # ft1 = 0.2f
flw ft2, 8(t0) # ft2 = 0.3f
fadd.s fa0, ft0, ft1 # rounded to nearest, ties to even (the default in fcsr)
feq.s a0, fa0, ft2 # comparison result goes to an integer register
li a7, 1
ecall # prints 1: in single precision the sum equals 0.3f
li a0, 10
li a7, 11
ecall
fmv.x.w a0, fa0 # copy the bits, unconverted, to an integer register
li a7, 34
ecall # prints 0x3e99999a
li a0, 10
li a7, 11
ecall
la t0, d01
fld ft0, 0(t0)
fld ft1, 8(t0)
fadd.d fa0, ft0, ft1 # the same sum in double precision
li a7, 3
ecall # prints 0.30000000000000004
li a7, 10
ecall
Next#
The Foundations section is complete: we know what a stored-program computer does, and how its memory represents integers, characters and real numbers as bits. The next section turns to the instructions that operate on those bits. The next note describes the processor as a programmer sees it, its registers, memory and instructions, and the instruction set architecture as the contract between hardware and software, using RISC-V and the RARS simulator.
References#
- A. Tatarnikov. Computer Architecture and Operating Systems (HSE), lecture 7: floating-point format.
- IEEE. IEEE Standard for Floating-Point Arithmetic, IEEE Std 754-2019. §3.4 (binary interchange format encodings), §4.3 (rounding-direction attributes), §6 (infinity, NaNs and the sign bit), §7 (exceptions).
- D. Goldberg. What every computer scientist should know about floating-point arithmetic. ACM Computing Surveys, 23(1), 1991. §1.2 (relative error and ulps), §1.3–1.4 (guard digits, cancellation), §2 (the IEEE standard).
- N. J. Higham. Accuracy and Stability of Numerical Algorithms, 2nd ed. SIAM, 2002. §2.2 (the standard model of floating-point arithmetic), §4.3 (compensated summation).
- R. E. Bryant, D. R. O’Hallaron. Computer Systems: A Programmer’s Perspective, 3rd ed. Pearson, 2016. §2.4 (floating point).
- D. A. Patterson, J. L. Hennessy. Computer Organization and Design, RISC-V Edition, 2nd ed. Morgan Kaufmann, 2020. §3.5 (floating point, including the RISC-V F and D instructions).
- A. Waterman, K. Asanović (eds.). The RISC-V Instruction Set Manual, Volume I: Unprivileged ISA. RISC-V International. Chapters on the F extension (registers,
fcsr, rounding modes, NaN generation, subnormals, fused multiply-add,fmv.x.w) and the D extension (NaN boxing). - P. Micikevicius et al. Mixed precision training. ICLR, 2018. §3.2 (loss scaling).
- D. Kalamkar et al. A study of BFLOAT16 for deep learning training. arXiv:1905.12322, 2019.
- P. Micikevicius et al. FP8 formats for deep learning. arXiv:2209.05433, 2022. Table 1 (E4M3 and E5M2).