Subscribe
AI
7 min read

What Is a Floating-Point Number? The Bit Layout That Sets the Limits of AI Math

fp32, fp16, bfloat16, TF32 and FP8 decide how precisely an AI model can count. A plain-English explainer of the number format under every training run.

Olivetti brochure style cover: a ribbon of bit cells with sign, exponent and mantissa fields expanded below under the headline What Is a Floating Point Number?
Olivetti brochure style cover: a ribbon of bit cells with sign, exponent and mantissa fields expanded below under the headline What Is a Floating Point Number?

Every large language model is, at the hardware level, a machine for adding and multiplying approximations. The weights in a 70-billion-parameter model are not exact numbers; they are 16-bit sketches of numbers, chosen because they fit in memory and multiply fast. The format that defines how far those sketches can drift from the truth is called floating-point, and almost every number an AI system touches is shaped by it.

Sign, exponent, fraction: the three fields

A floating-point number is binary scientific notation. Instead of writing a number as a string of digits, a computer splits it into three pieces: a sign bit (positive or negative), an exponent (which scale of magnitude the number lives at), and a fraction or mantissa (the significant digits themselves). David Goldberg's 1991 survey What Every Computer Scientist Should Know About Floating-Point Arithmetic, still the standard reference, describes the layout and the rounding rules it implies.

The bit budget decides everything. The familiar 32-bit format (fp32) spends 1 bit on sign, 8 on the exponent and 23 on the stored mantissa bits. The 64-bit format scientists use (fp64) widens those fields to 1 and 11 and 52. Two design lessons follow immediately:

  • The exponent is reach. Eight bits of exponent let fp32 represent magnitudes from roughly 10^-38 up to 10^38. Five bits, as in fp16, cap the largest number at about 65,000 Wikipedia: half-precision format.
  • The mantissa is granularity. The mantissa decides how finely numbers are spaced at any given magnitude. fp32's 24 effective significand bits buy just over seven decimal digits of precision; bfloat16's 8 buy about two and a half.

Granularity is relative. The gap between two representable numbers around 1.0 is tiny; around 10 million it is wide. That is why the same format that can hold 0.0000001 can also quietly swallow a 1 added to a large number.

Abstract stacked bars contrasting three ways to divide a fixed bit budget between exponent reach and mantissa precision

Why 0.1 is not 0.1

Most decimal fractions have no exact binary representation. Goldberg's paper notes plainly that "0.1 cannot be represented exactly in binary" in any fixed-precision machine, so code that divides by 10 and code that multiplies by 0.1 do not mean the same thing. Worse, the associative law fails: as Goldberg puts it, "(x+y)+z can have a totally different answer than x+(y+z)". Summing 1,000 gradients in one order and the same 1,000 in another order can produce different bits. This is the root of the well-known result that GPU training and inference at temperature 0 are not fully reproducible: parallel reductions add numbers in orders that depend on batch shape and kernel scheduling.

A number line whose representable values are dense small steps on the left and grow to coarse wide gaps on the right, with a value marked in the gap between two steps

From a Berlin relay computer to a 1985 treaty

Floating-point predates AI by half a century. Konrad Zuse's Z3, finished in 1941, was binary and already floating-point, with a 22-bit word; the Computer History Museum timeline records it performing "floating point binary arithmetic" on 2,300 relays. What it lacked was any cross-machine agreement on how the fields, special values like infinity, and rounding should behave.

That agreement arrived as IEEE 754-1985, the standard that still defines how nearly all computers do arithmetic. Its chief architect was William Kahan of UC Berkeley, who received the 1989 ACM Turing Award for the work and is often called the father of floating point. The standard was revised in 2008 and again in 2019; the 2008 revision is what added the 16-bit binary16 format, better known as fp16, as a standard member (IEEE 754).

Note the chronology: the 16-bit format AI depends on is younger than the 32-bit one by 23 years, and the ML-specific formats below are not IEEE standards at all.

Why AI dropped to 16 bits

Full 32-bit precision was always a compromise, and for neural networks it turned out to be an expensive one. In 2018, a team from NVIDIA and Google DeepMind published Mixed Precision Training (Micikevicius, Narang, Alben et al.), demonstrating that networks could train at IEEE half precision (fp16) with no accuracy loss if three techniques were added: keep a master copy of the weights in fp32, scale the loss upward so tiny gradients do not underflow to zero (fp16 "has a narrower dynamic range than FP32," the paper says), and accumulate fp16 products in fp32. Because activations are stored in half precision, "the overall memory consumption for training deep neural networks is roughly halved," and the authors measured 2-6x speedups on Volta GPUs where memory or arithmetic bandwidth bound the job.

OpenAI's GPT-3 paper credits Prafulla Dhariwal with developing the "memory optimizations for fully half-precision training" that trained the 175-billion-parameter model. By 2020, 16-bit training was the default, not the exception.

Bfloat16: keep the exponent, slash the mantissa

The industry-standard fp16 has a problem for training: 5 exponent bits mean activations and gradients overflow around 65,000 and underflow quickly near zero, forcing the loss-scaling gymnastics above. Google's answer, built into its TPUs years earlier, was bfloat16: a 16-bit format that spends 1 bit on sign, a full 8 on the exponent and only 7 on the mantissa. In the format's reference post, Google states the design bet directly: "neural networks are far more sensitive to the size of the exponent than that of the mantissa." Bfloat16 therefore keeps fp32's dynamic range exactly ("to ensure identical behavior for underflows, overflows, and NaNs, bfloat16 has the same exponent size as FP32"), trades away most digit-level precision, and works "as well as the FP32 format" on Google's models while cutting memory use. The Llama 3 team's model card paper likewise runs BF16 inference across 16 GPUs in its scale examples.

This is the trade most people miss when they talk about "16-bit models": bfloat16 is not more precise than fp16. It is roughly 16 times less precise per number (7 mantissa bits vs 10), but it never runs out of room.

TF32 and FP8: the slider keeps moving

NVIDIA's A100 took a middle path with TensorFloat-32 in 2020: a compute mode inside tensor cores that uses "8 exponent bits and 10 mantissa bits to match the FP32 value range while maintaining precision equivalent to FP16." Frameworks still see fp32 tensors; the chip silently rounds inputs to 19 significant bits, multiplies, and accumulates in fp32, which NVIDIA measured as up to 8x matrix throughput versus the fp32 datapath.

FP8 pushed one step further. The FP8 Formats for Deep Learning paper (Micikevicius, Stosic, Burgess, Cornea et al.) proposed two 8-bit encodings: E4M3 (4 exponent bits, 3 mantissa bits, largest finite value 448) for weights and activations, and E5M2 (5 exponent, 2 mantissa) for gradients where range matters more than granularity, with per-tensor scale factors recovering the missing range. The paper reports FP8 training matching 16-bit quality across CNNs, RNNs and Transformers, including language models up to 175 billion parameters, with no hyperparameter changes. NVIDIA's H100 made it silicon: its architecture writeup describes "New NVIDIA Hopper FP8 precisions: 2x throughput and half the footprint of H100 FP16 or BF16." Meta then shipped Llama 3.1 405B in production by applying "FP8 quantization to most matrix multiplications inside the model," using the H100's native support.

What this means for what your model says

Three consequences are worth keeping in mind.

First, model quality is astonishing despite the arithmetic. A frontier model's loss curve, its 70 billion weights and every token of its output are computed on numbers with two to seven decimal digits of granularity. That the results are coherent at all is evidence that neural-network optimization is remarkably noise-tolerant, which is exactly the premise of bfloat16.

Second, some error is structural. Rounding is not random noise you can average away by adding more bits at the end; summation order genuinely changes results (Goldberg), which is why providers can run the same prompt through a different batch composition or a new kernel and produce a different continuation even at temperature 0.

Third, the number formats are where efficiency debates actually happen. When a serving provider says it doubled throughput or halved your per-token price, the mechanism is usually bit-width: fewer exponent and mantissa bits per number, wider tensor instructions, less memory traffic. Quantization to 4-bit and 8-bit integers for inference is a separate family of tricks (fixed-point, not floating-point), but the economic logic is the same one that took fp32 out of frontier training.

Floating point began as a way to make one relay computer in Berlin do aerodynamics, was standardized in 1985 to make programs portable across machines, and ended up as the constraint surface every modern AI model runs on. It decides the largest number a gradient can hold, the smallest difference a loss can feel, and how many decimal digits of your model's "knowledge" actually exist.

Sources

AILLMeducational