bfloat16 Inspector

Inspect Google Brain's 16-bit bfloat16 floating-point format

Decode or encode bfloat16 values: see the sign bit, 8-bit exponent, and 7-bit mantissa used by ML hardware like TPUs. Convert a decimal number to its nearest bfloat16, or a 16-bit hex value back to a real number. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How is bfloat16 different from IEEE-754 half-precision (float16)?

bfloat16 uses an 8-bit exponent and 7-bit mantissa, while float16 uses a 5-bit exponent and 10-bit mantissa. bfloat16 keeps float32's full dynamic range but with fewer significant digits, which suits deep-learning training where range matters more than precision.

bfloat16 (brain floating point) is a 16-bit format that keeps the full exponent range of a 32-bit float while throwing away most of its precision. This inspector lets you encode a decimal number into its nearest bfloat16 and decode any 16-bit pattern back into the real number it represents, showing every field.

Bit layout

A bfloat16 packs three fields into 16 bits:

bit 15    bits 14..7     bits 6..0
sign(1)   exponent(8)    mantissa(7)

The exponent uses a bias of 127 — identical to float32. For a normal value:

value = (-1)^sign × (1 + mantissa/128) × 2^(exponent − 127)

When the stored exponent is 0 the value is subnormal (no implicit leading 1) or zero; when it is 255 the value is infinity (mantissa 0) or NaN. Because bfloat16 is literally the top 16 bits of a 32-bit IEEE-754 float, converting between them is trivial — just truncate or pad the mantissa.

Why bfloat16 exists: float32 range without float32 memory

Standard IEEE-754 half-precision (float16) uses a 5-bit exponent, limiting its dynamic range to roughly ±65504. During deep-learning training, activations and gradients can span many orders of magnitude; float16 overflows or underflows, causing diverging loss. bfloat16 solves this by keeping float32’s 8-bit exponent (range ±3.4 × 10³⁸) but compressing the mantissa from 23 bits down to 7. The result is coarser precision (~2–3 significant decimal digits) but the same dynamic range as float32, at half the memory and bandwidth.

Decoding examples

HexSignExponent (stored)MantissaDecoded value
3F80012701.0 (exactly)
4000012802.0 (exactly)
3E200124320.15625 (exactly)
3DCC012376≈ 0.0996 (nearest to 0.1)

Enter 0.1 in the encode direction to see how bfloat16 stores it as 0x3DCC — a value that decodes back to about 0.0996, showing the precision loss. That ~0.4% error is typically acceptable for neural-network weights but would be catastrophic for financial calculations.

Hardware and framework support

bfloat16 is natively supported on Google TPUs, NVIDIA Ampere and later GPUs (A100, H100), Intel Xeon Scalable processors (AVX-512 BF16), and ARM processors with BF16 extensions. PyTorch and TensorFlow both support torch.bfloat16 and tf.bfloat16 dtypes for mixed-precision training, typically keeping model parameters in float32 but running forward passes in bfloat16 to halve memory.

All calculations run in your browser — nothing is uploaded.