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
| Hex | Sign | Exponent (stored) | Mantissa | Decoded value |
|---|---|---|---|---|
3F80 | 0 | 127 | 0 | 1.0 (exactly) |
4000 | 0 | 128 | 0 | 2.0 (exactly) |
3E20 | 0 | 124 | 32 | 0.15625 (exactly) |
3DCC | 0 | 123 | 76 | ≈ 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.