Skip to content
mlmentorship

Floating-point formats: FP32, FP16, BF16, FP8, TF32

Separate exponent range, local rounding, accumulation and storage using checked FP16, BF16 and integer examples.

Published · 10 min read ·Core ·Intermediate

Visual quick review

Explain how moving three bits from the fraction to the exponent gives BF16 FP32-like range but makes adjacent values near one eight times farther apart than FP16.

Same storage, different rounded value

Spend bits on range or resolution; distinguish rounding, overflow, and scaled-integer saturation

Spend bits on range or resolution; distinguish rounding, overflow, and scaled-integer saturationBoth sixteen-bit formats trade exponent range against fraction resolution. Near one, BF16 spacing is eight times wider: 1.003 rounds to one, while FP16 keeps about 1.00293. At 70000, FP16 overflows but BF16 remains finite and inexact. Accumulation precision is separate. Scaled INT8 instead maps values to bounded integer codes; finer scale improves local resolution but narrows range. Saturation is not rounding noise.Sixteen slots. Three change jobs.FP161 sign; 5 exponent; 10 fractionBF161 sign; 8 exponent; 7 fractionBlue buys range. Green buysprecision.The total bit budget never grows.Nearest-even rounding of 1.003Both rulers span one BF16 step aboveone; red marks the requested value.FP16: eight smaller steps11.0078125Stored: 1.0029296875BF16: one wide step11.0078125Stored: 1At 70000: FP16 overflows; BF16 stores70144, finite but inexact.Accumulation precision is a separatechoice.Scaled INT8 is not anexponent/fraction layoutScale 0.1: 0.26 uses code 3 andreconstructs 0.3.Scale 0.01 retains 0.26, but narrowsthe signed-code range.At scale 0.1, value 20 clamps to code127 and reconstructs 12.7. Finerlocal rounding cannot undosaturation.
Read it this way: Both sixteen-bit formats trade exponent range against fraction resolution. Near one, BF16 spacing is eight times wider: 1.003 rounds to one, while FP16 keeps about 1.00293. At 70000, FP16 overflows but BF16 remains finite and inexact. Accumulation precision is separate. Scaled INT8 instead maps values to bounded integer codes; finer scale improves local resolution but narrows range. Saturation is not rounding noise. Does wider range preserve smaller updates?
Full explanation 10 min read
Reading depth

Summary

A floating-point format spends bits on magnitude range and local precision. More exponent bits do not preserve smaller relative updates.

Round to FP16 and BF16 using round-to-nearest-even. Both use sixteen bits, but FP16 has ten fraction bits and BF16 has seven. Which format retains more of this change from one?

FP16 vs. BF16: range vs. precision

For normal values, decode sign , fraction and unbiased exponent as . With fraction bits, spacing within is .

Same storage, different rounded value

Actual rounded bit fields for 1.003

Actual rounded bit fields for 1.003 Both rows use sixteen bits. FP16 has sign zero, biased exponent 01111 and fraction 0000000011, encoding 1.0029296875. BF16 has sign zero, biased exponent 01111111 and fraction 0000000, encoding exactly one. Field widths are proportional to their bit counts. FP16: 1.0029296875 0 01111 0000000011 BF16: 1 0 01111111 0000000 Fields from left: sign, exponent, fraction

FP16: 1 sign + 5 exponent + 10 fraction

More fraction bits make nearby values finer; fewer exponent bits narrow the normal range.

FieldBitsWhat those bits buy
Exponent5normal magnitudes ≈ 6.10 × 10−5 to 6.55 × 104
Fraction10next value after 1 is 1 + 2−10 ≈ 1.00098

Failure mode: values below the narrow range become subnormal, then zero.

BF16: 1 sign + 8 exponent + 7 fraction

More exponent bits preserve FP32-like range; fewer fraction bits make nearby values coarser.

FieldBitsWhat those bits buy
Exponent8normal magnitudes ≈ 1.18 × 10−38 to 3.39 × 1038
Fraction7next value after 1 is 1 + 2−7 ≈ 1.00781

Failure mode: updates can round away because adjacent values are farther apart.

Read it this way: each row has the same width. BF16 allocates more bits to the exponent, leaving fewer fraction bits. Its broader range does not preserve the 0.003 change near one.
Check: Why can BF16 have broader range yet round away the 0.003 change retained by FP16?
Reference drawing

Same storage, different rounded value

Spend bits on range or resolution; distinguish rounding, overflow, and scaled-integer saturation

Spend bits on range or resolution; distinguish rounding, overflow, and scaled-integer saturationBoth sixteen-bit formats trade exponent range against fraction resolution. Near one, BF16 spacing is eight times wider: 1.003 rounds to one, while FP16 keeps about 1.00293. At 70000, FP16 overflows but BF16 remains finite and inexact. Accumulation precision is separate. Scaled INT8 instead maps values to bounded integer codes; finer scale improves local resolution but narrows range. Saturation is not rounding noise.Sixteen slots. Three change jobs.FP161 sign; 5 exponent; 10 fractionBF161 sign; 8 exponent; 7 fractionBlue buys range. Green buysprecision.The total bit budget never grows.Nearest-even rounding of 1.003Both rulers span one BF16 step aboveone; red marks the requested value.FP16: eight smaller steps11.0078125Stored: 1.0029296875BF16: one wide step11.0078125Stored: 1At 70000: FP16 overflows; BF16 stores70144, finite but inexact.Accumulation precision is a separatechoice.Scaled INT8 is not anexponent/fraction layoutScale 0.1: 0.26 uses code 3 andreconstructs 0.3.Scale 0.01 retains 0.26, but narrowsthe signed-code range.At scale 0.1, value 20 clamps to code127 and reconstructs 12.7. Finerlocal rounding cannot undosaturation.
Derivation
Actual rounded bit fields for 1.003 Both rows use sixteen bits. FP16 has sign zero, biased exponent 01111 and fraction 0000000011, encoding 1.0029296875. BF16 has sign zero, biased exponent 01111111 and fraction 0000000, encoding exactly one. Field widths are proportional to their bit counts. FP16: 1.0029296875 0 01111 0000000011 BF16: 1 0 01111111 0000000 Fields from left: sign, exponent, fraction

FP16: 1 sign + 5 exponent + 10 fraction

More fraction bits make nearby values finer; fewer exponent bits narrow the normal range.

FieldBitsWhat those bits buy
Exponent5normal magnitudes ≈ 6.10 × 10−5 to 6.55 × 104
Fraction10next value after 1 is 1 + 2−10 ≈ 1.00098

Failure mode: values below the narrow range become subnormal, then zero.

BF16: 1 sign + 8 exponent + 7 fraction

More exponent bits preserve FP32-like range; fewer fraction bits make nearby values coarser.

FieldBitsWhat those bits buy
Exponent8normal magnitudes ≈ 1.18 × 10−38 to 3.39 × 1038
Fraction7next value after 1 is 1 + 2−7 ≈ 1.00781

Failure mode: updates can round away because adjacent values are farther apart.

Read it this way: each row has the same width. BF16 allocates more bits to the exponent, leaving fewer fraction bits. Its broader range does not preserve the 0.003 change near one.
Check: Why can BF16 have broader range yet round away the 0.003 change retained by FP16?
Read it this way: Both sixteen-bit formats trade exponent range against fraction resolution. Near one, BF16 spacing is eight times wider: 1.003 rounds to one, while FP16 keeps about 1.00293. At 70000, FP16 overflows but BF16 remains finite and inexact. Accumulation precision is separate. Scaled INT8 instead maps values to bounded integer codes; finer scale improves local resolution but narrows range. Saturation is not rounding noise. Does wider range preserve smaller updates?

References: NVIDIA's IEEE 754 overview, Google Cloud's BF16 documentation, and the BFLOAT16 study.

In , FP16 spacing is . BF16 spacing is , eight times wider.

FormatRounded Absolute error
FP16
BF16

These are rounding errors in a fixture, not measurements of model quality.

Change the numerical requirement

1. Prioritize range

New task: store with the same rounding rule.

Picture and change: inspect the exponent range rather than only spacing near one.

Check: FP16 overflows because its largest finite value is . BF16 rounds to finite , not exact .

Use when: activations exceed FP16 range and BF16 rounding is acceptable for the application.

2. Store scaled integers

New task: store as signed INT8 with scale and zero point zero.

Picture and change: compute , then reconstruct . This is scaled integer quantization, not an exponent/fraction format.

Check: reconstructs , with error . Scale reconstructs exactly but narrows the representable range. For 1024 raw values, INT8 uses 1024 bytes versus BF16’s 2048 bytes, excluding metadata.

Use when: storage or bandwidth motivates quantization and calibration can establish a suitable scale.

Saturation is not rounding noise

At scale , exceeds INT8’s largest code. Clamping reconstructs instead. Finer rounding within the existing range cannot recover the clipped value.

Try the next exponent interval

What is BF16 spacing within ?

Check your answer

It is . Increasing the exponent doubles spacing while the fraction width stays fixed.

The standard layouts

The table gives approximate finite endpoints and normal minima. FP8 rows use the E4M3 finite-endpoint and E5M2 conventions described in FP8 Formats for Deep Learning.

FormatStored bitsExponent / fractionLargest finite magnitudeSmallest positive normal
FP32328 / 23
FP16165 / 10
BF16168 / 7
TF32 multiply input precisionFP32 storage8 / 10Approximately FP32 rangeApproximately FP32 normal range
FP8 E4M384 / 3
FP8 E5M285 / 2
Signed INT88NeitherCodes through Scale-dependent step
FP646411 / 52

FP16’s smallest positive subnormal is , below its normal minimum. Actual operations may flush subnormals to zero; representable values and hardware behavior are separate questions.

TF32: a hybrid for matmul accumulation

TF32 is an internal multiply-input precision, not a packed nineteen-bit tensor dtype. Its reduced fraction precision and FP32 accumulation describe separate stages. Check the actual operation, library version and enabled precision policy; defaults and speedups are not universal.

FP8: the new training format

OFP8 E4M3 has more fraction precision and a smaller finite range than E5M2. E4M3’s finite-endpoint convention has no infinity encoding; E5M2 includes infinities. Other FP8 variants have different endpoint conventions. Scaling, tensor placement and accumulation precision are part of a training recipe, not implied by the bit count.

INT8: the inference format

Affine quantization adds a zero point : . Reconstruction is . Per-tensor, per-channel and grouped scales trade metadata and kernel support against quantization error.

INT4 / NF4 / GPTQ: aggressive inference quantization

INT4 stores sixteen codes; its reconstruction depends on scales and zero points. NF4 uses nonuniform levels motivated by a normal-weight distribution. GPTQ and AWQ are distinct quantization methods, not scalar floating-point formats. Evaluate the actual model, calibration distribution, kernels and downstream quality.

Choosing precision by operation

TaskFormat
TrainingSelect parameter, activation, reduction and optimizer-state precision separately
FP16 backwardConsider loss scaling; unscale before clipping and optimizer updates
BF16 backwardBroader range often avoids loss scaling, but coarse updates can still disappear
InferenceCheck weight, activation and KV-cache quantization independently
Memory-limited deploymentInclude scales, metadata, workspace and kernel support, not only raw weight bits

Common pitfalls

Loss scaling does not repair low-precision master-weight rounding or incorrect arithmetic. Reduced-precision optimizer states need a validated recipe; FP32 is not a universal theorem or the only workable choice. Throughput comparisons must state format, sparsity, operation and workload.