DEV Community

Cover image for How GPUs Really Store Numbers: An Interactive Tour of FP32, BF16, FP8, and FP4 for AI
Dmitry Noranovich
Dmitry Noranovich

Posted on

How GPUs Really Store Numbers: An Interactive Tour of FP32, BF16, FP8, and FP4 for AI

This page presents an interactive Number to GPU Float Converter that demonstrates how any decimal number is stored and approximated across the main floating-point formats used by GPUs in AI workloads. Users enter a value and immediately see the results in FP64, FP32, TF32, FP16, BF16, FP8 E4M3, FP8 E5M2, and FP4 E2M1. The tool highlights the practical trade-offs between numerical precision, dynamic range, memory footprint, and compute throughput that arise when reducing bit width.

The converter covers the full spectrum of formats relevant to modern machine learning. FP32 serves as the stable baseline, TF32 trims the mantissa for faster tensor-core math while retaining FP32 range, FP16 and BF16 each use 16 bits with different priorities (precision versus range), the two FP8 variants further split bits between exponent and mantissa, and raw FP4 is shown as an extreme low-precision option that normally requires block scaling (as in MXFP4 or NVFP4) to be useful. FP64 is provided purely as a high-precision reference.

Under the hood the page walks through the standard binary floating-point encoding process: determining the sign bit, normalizing the magnitude into the form 1.mantissa × 2^exponent, applying the format-specific bias, rounding the mantissa to fit the available bits (typically round-to-nearest-even), packing the bits, and decoding the stored value back to decimal. A detailed step-by-step example converts 13.625 into FP8 E4M3 and shows why it becomes 14, illustrating the rounding error that appears once the mantissa is truncated. The same principles explain special values (zeros, subnormals, infinity, and NaN) and why smaller formats can underflow, overflow, or collapse nearby numbers.

Practical examples and guidance complete the article. Numbers such as 0.1, 1.1, 0.00009, and 449 demonstrate how approximation behaves differently across formats, while the text emphasizes that lower precision is valuable for memory and speed only when the hardware and software stack support it and when scaling or mixed-precision techniques are applied carefully. The overall message is that these formats are engineering compromises: fewer bits enable larger models and higher throughput, but they require awareness of the resulting numerical limitations.

Ready to put the theory into practice?

→ Join https://www.reddit.com/r/AIProgrammingHardware for discussions, benchmarks, and expert tips on AI hardware and low-precision training.

→ Experiment live with the Number-to-GPU-Float Converter at https://www.bestgpusforai.com/calculators/number-to-GPU-float-converter convert numbers across NVIDIA float formats in seconds and see the precision trade-offs yourself.

Top comments (0)