IEEE-754 half precision packs a floating-point number into just 16 bits, trading range and precision for compactness. It is the fp16 of machine learning and the half of GPU shaders. This inspector decodes every bit so you can see exactly what a half-float represents and encodes any decimal into its nearest half.
Bit layout
bit 15 bits 14..10 bits 9..0
sign (1) exponent (5) mantissa (10)
The exponent uses a bias of 15. For normal numbers (stored exponent 1–30):
value = (-1)^sign × 1.mantissa × 2^(stored_exponent − 15)
The implicit leading 1. is not stored. When the exponent is all zeros the number
is subnormal: the implicit bit becomes 0 and the effective exponent is fixed at
−14. An all-ones exponent with zero mantissa means infinity; non-zero mantissa
means NaN.
Key limits of float16
| Property | Value |
|---|---|
| Largest finite value | 65504 (0x7BFF) |
| Smallest positive normal | 2^−14 ≈ 0.0000610 |
| Smallest positive subnormal | 2^−24 ≈ 5.96 × 10^−8 |
| Significant decimal digits | ~3–4 |
Worked examples
Encoding 1.0: sign 0, true exponent 0 → stored 15, mantissa 0.
Hex: 0x3C00. Decodes back to 1.0 exactly.
Encoding 65504: the largest finite half. Hex: 0x7BFF.
The next representable value would need exponent field = 31, which means infinity.
Encoding 0.1: not exactly representable. The nearest half is 0x2E66,
which decodes to approximately 0.0999756. The rounding error is about 0.024%
— larger than in float32 or float64, which is why float16 is unsuitable for
financial calculations.
Encoding 100000: overflow. This exceeds 65504, so the result is +Infinity
(0x7C00). Float16’s limited range (versus bfloat16’s 10^38 range) is why the
ML community sometimes prefers bfloat16 for training.
float16 vs bfloat16 — when to use which
Float16 has 10 mantissa bits (~3–4 decimal digits of precision) but only a 5-bit exponent (range ±65504). bfloat16 has only 7 mantissa bits (~2–3 digits of precision) but an 8-bit exponent matching float32’s full range (±3.4 × 10^38). In practice: float16 is common in graphics (GPU shaders, image data) where values fit in the ±65504 range; bfloat16 is preferred for deep-learning training where gradient magnitudes can be much larger.
Common uses of float16
- GPU shaders: graphics APIs (Metal, Vulkan, WebGPU) natively support
halffor intermediate calculations where 3–4 digits of precision is enough and bandwidth is at a premium. Texture coordinates, color components (0–1 range), and lighting coefficients all fit well within float16’s range and precision. - Neural network inference: once a model is trained, its weights can be quantized to float16 for deployment with minimal accuracy loss, halving the memory footprint on edge hardware.
- Scientific data compression: sensor readings with limited precision (e.g., temperature to 0.1°C, GPS altitude to 1 m) can often be stored in float16 rather than float32, reducing storage or transmission size by half.
All calculations run in your browser — nothing is uploaded or stored.