BITS · ROUNDING · REPRESENTABLE VALUES

FP32, BF16 and FP16: inspect range and rounding

Enter an actual value. Inspect its sign, exponent and fraction bits, then pause at the boundaries where a format rounds, underflows or overflows.

Nearest-even rounding · subnormals preserved

On narrow screens, scroll the diagram horizontally or focus it and use the arrow keys to inspect full-size labels. Exact values follow below.

Values and errors

FormatClassificationValueHex bitsAbsolute errorRelative error

FP32 error is relative to the JavaScript-parsed input number. BF16/FP16 errors are relative to the rounded FP32 value. Errors for NaN/infinity are not defined; zero converted to zero has zero relative error. Decimal displays are rounded to 12 significant digits; hexadecimal encodings are exact.

Your experiment

Inspect the FP16 smallest subnormal: 2⁻²⁴. Its encoding must be 0x0001, not zero or an FP32 subnormal. Compare it with 2⁻²⁵, which lies halfway between zero and that smallest FP16 value and rounds to even zero.

Choose the two midpoints near one. Ties round to an even retained fraction, not always upward. Then compare 65,504 with 65,520: the first is FP16’s largest finite value; the second rounds to infinity.

Enter 0.1 and notice that even the FP32 row has a small nonzero error. Enter −0 and inspect the sign bit. Choose NaN and confirm that it stays NaN in every format.

Range is not the same as precision

FP32 stores 8 exponent and 23 fraction bits; BF16 stores 8 and 7; FP16 stores 5 and 10. The implicit leading bit adds one significand bit for normal values, but not subnormals.

FP32 and BF16 share exponent width and minimum normal magnitude 2⁻¹²⁶, but not exactly the same finite range: maximum FP32 is approximately 3.40282347×10³⁸; maximum BF16 is approximately 3.38953139×10³⁸. Their smallest positive subnormals are 2⁻¹⁴⁹ and 2⁻¹³³ respectively.

FP16’s minimum normal is 2⁻¹⁴ and smallest positive subnormal is 2⁻²⁴. These distinctions matter near zero and overflow; no format is universally best for every training workload.

This is a bit-level numerical conversion model, not a GPU or training benchmark. It uses round-to-nearest, ties-to-even, preserves subnormals and signed zero, and canonicalizes some NaN payloads. It deliberately converts the parsed binary64 JavaScript number to FP32 before the 16-bit downcasts; it is not arbitrary-precision decimal conversion or a direct binary64-to-FP16 operation. Hardware kernels may use different accumulation, flushing or rounding behavior. ECMAScript floating-point rounding · Machine-learning numeric formats.

Floating-Point Range and Rounding: Control Guide: experiment guide

Decimal or special value accepts signed decimal numbers, scientific notation, Infinity, −Infinity and NaN. Use an ASCII minus in the input field. The number first passes through JavaScript parsing, then rounds to FP32; BF16 and FP16 subsequently round that FP32 value using nearest-even rounding. This conversion path matters: direct rounding from an arbitrary higher-precision decimal to a smaller format can differ from a two-stage conversion near a midpoint. The model preserves subnormals and signed zero. It does not emulate a processor mode that flushes small values to zero, and it does not claim to represent arbitrary decimal input exactly.

Worked details 1

Boundary preset selects a reproducible input and immediately updates the result. Inspect value explicitly repeats the same inspection; typing also updates immediately. Custom value keeps the current text rather than generating a random example. Each format row reports classification, rounded value, exact hexadecimal encoding, absolute error and relative error. The canvas separates sign, exponent and stored fraction bits; the table supplies the same encoding as accessible text. FP32 errors compare against the parsed JavaScript number. BF16 and FP16 errors compare against rounded FP32, so the rows intentionally use different reference values. Error for infinity or NaN is undefined. Zero converted to zero has zero relative error; signed zero remains visible in the value and sign bit.

Worked details 2

Enter 1.00390625, the BF16 midpoint between 1 and 1.0078125. BF16 rounds to 1 with hexadecimal 3f80 because the retained fraction is even. Enter 1.01171875, the next midpoint: BF16 rounds upward to 1.015625, hexadecimal 3f82, demonstrating that ties do not always round downward. Inspect 65504 and then 65520: FP16 changes from its largest finite value, hexadecimal 7bff, to infinity, hexadecimal 7c00. BF16 remains finite for these inputs. Enter 5.960464477539063e-8 to see the smallest FP16 subnormal with encoding 0001, then halve it to observe a tie that rounds to zero. A blank field or malformed text produces validation feedback rather than a stale result.

Worked details 3

Play boundary tour walks nine selected boundaries over sixty teaching seconds, starting with zero. The first eight begin at 7.5-second intervals, and the final large-FP32 boundary appears at sixty seconds. Pause tour freezes its progress. Next boundary pauses and advances one boundary; from manual mode it starts at zero. Restart tour pauses at zero and replaces the input with that first boundary. Tour time seeks directly to a paused point. Speed offers 0.25, 0.5, 1 or 2 times the teaching rate. Entering a value or choosing a preset stops the tour and returns to manual inspection. Restart preserves the selected speed, and there is no parameter-reset button. These seconds are for reading bit patterns, not processor conversion latency. This instrument evaluates representation, not training stability, loss scaling, throughput or model accuracy.

Views are my own and do not represent any employer, past or present.