Main Point: The number format affects storage, the values a system can represent and the detail it retains. Choose it by measuring memory use and task quality together.
Key Points
- Eight bits make one byte; a 32-bit value uses four bytes.
- Range and precision describe different properties of a number format.
- FP16 and BF16 both use 16 bits but have different numerical behaviour.
1. The Representation Decision
- An umbrella retailer has a numerical model for planning stock. It stores many values, moves them through memory, and uses them in calculations.
- Someone proposes a smaller number format to save space and make the work faster. That sounds attractive.
- But what details might the new format lose, and how would the retailer know whether the change is useful?
| Format Size | Bytes Per Value | Payload For 1 Million Values |
|---|---|---|
| 32 bits | 4 | 4,000,000 bytes |
| 16 bits | 2 | 2,000,000 bytes |
| 8 bits | 1 | 1,000,000 bytes |
| 4 bits, ideal packing | 0.5 | 500,000 bytes |
Boundary: Numerical payload only. Packing, metadata and runtime state add requirements.
2. Bits, Bytes, and Nominal Payload
- Computers store numbers using defined patterns of bits. A bit has two possible states.
- Eight bits make one byte. If one value occupies thirty-two bits, it uses four bytes, because thirty-two divided by eight is four.
- A sixteen-bit value uses two bytes. An eight-bit value uses one.
- A four-bit value takes half a byte in a simple payload calculation, so two four-bit values can in principle fit into one byte. Actual formats need particular packing and sometimes other information.
- A half-byte figure by itself is not a promise about the memory required by a real model.
- Consider a hypothetical array of one million values for the retailer. At four bytes each, thirty-two-bit values give four million bytes of numerical payload.
- At two bytes each, sixteen-bit values give two million bytes. Eight-bit values give one million bytes.
- If four-bit values are packed two per byte, the nominal payload is five hundred thousand bytes.
- Those are arithmetic results for the values alone. They leave out other model state, temporary work, metadata, layout requirements and software overhead.
- The byte count helps estimate what fits and how much data must move. A real deployment also needs supporting information and runtime memory.
3. Range, Precision, and Lost Detail
- A smaller format offers fewer bit patterns, so it has to make choices about which values those patterns stand for. Two ideas help us judge those choices.
- Numerical range asks about the magnitudes the format can represent: how large or how tiny a value can be under its rules. Precision asks how finely it can distinguish values, or how close representable values can be in a part of that range.
- These are related, but they are not the same. A format can cover a broad span of magnitudes while leaving larger gaps between neighboring values at some magnitudes.
- Consider a familiar decimal analogy. Suppose the retailer stores a measurement to the nearest whole unit.
- One point two and one point four both become one. The stored value cannot tell those two measurements apart.
- If the retailer keeps one decimal place, they remain one point two and one point four. More detail has been preserved.
- The decimal rounding example illustrates lost detail. Actual floating-point formats use structured binary patterns.
- The practical question is still useful: could two values that matter to the task become indistinguishable, or could a calculated value move enough to change the result?
4. Floating-Point Roles and Format Choices
- Floating-point formats usually divide their bits among three roles. A sign indicates whether the number is positive or negative.
- An exponent helps represent scale. A significand carries meaningful digits within that scale.
- Ordinary scientific notation gives an intuition. In −3.2 × 10^4, the minus sign gives direction, the exponent 4 gives scale, and 3.2 carries the significant digits.
- Computer floating point uses binary rules rather than this exact decimal form, but the roles of sign, scale and detail are similar.
- With a fixed total number of bits, the allocation among those roles affects both range and precision. More reach across magnitudes does not automatically mean finer detail at every magnitude.
- And a format that preserves small differences in one region may have a narrower useful range elsewhere. We need to know the format's rules and the values our task will actually produce.
- Think of the retailer's demand scores. If only a rough ranking matters, some small differences may be harmless.
- If a score near a threshold changes a stock decision, a small numerical change may matter. The format does not decide the business consequence by itself; the retailer needs a task-level check.
- FP32 is a thirty-two-bit floating-point format widely used for numerical computing. FP16 uses sixteen bits.
- BF16, short for bfloat16, also uses sixteen bits. FP16 and BF16 each have a nominal two-byte payload per value, but their bits are allocated differently between scale and fraction detail.
- BF16 preserves a broad exponent range while carrying fewer fraction bits than FP32. FP16 uses a different exponent and fraction allocation.
- As a result, two sixteen-bit formats can differ in the magnitudes they handle and in the spacing between representable values. Equal storage size does not make their numerical results interchangeable.
- You may also hear FP8 and FP4. Those names refer to smaller floating-point categories, not one universal eight-bit or four-bit rule.
- Format choices can differ in range, scaling and hardware support. A device that handles one such format efficiently may not support another in the same way.
- Integer quantization is another approach to compact representation. A four-bit integer scheme and a four-bit floating-point scheme share a bit count, but not necessarily the same mapping of stored patterns to numerical values.
- Compare range, precision, scaling and hardware support alongside the format label and bit count.
5. Resource Gains and Numerical Consequences
- Consider the retailer's million-value array. A smaller nominal payload can make it easier to fit values in available memory and reduce the amount that must move through a memory path.
- If the hardware and software support efficient computation in that format, the same device may complete more suitable operations in a given time or use less energy for them.
- Each “if” matters. A smaller value is not guaranteed to make the full service faster.
- Another stage may dominate. The device may lack a suitable fast path, or arranging the new format may add work.
- We would measure actual memory use, movement, elapsed time and energy under the intended workload, not infer them all from the bit count.
- We would also check the model's useful output. The retailer may care whether stock estimates stay good enough, and whether a small set of consequential cases becomes worse.
- A format that saves memory but changes important results can be an expensive bargain.
- Rounding is one source of change. When an exact value has no matching pattern in the chosen format, it must be represented according to that format's rules.
- Small errors can accumulate across repeated calculations. Some computations are especially sensitive to such changes, and an unstable sequence can amplify an initially small difference.
- Range limits create other problems. Overflow occurs when a quantity exceeds what the format can represent under the operation's behavior.
- Underflow concerns a value too small for the ordinary representable range; the exact handling depends on the format and operation. We should not assume every underflow simply becomes zero, or that every overflow looks the same.
- For these reasons, some training procedures use lower-precision inputs for parts of the work while accumulating results or keeping selected state at higher precision. Mixing formats is a deliberate design choice.
- It can preserve behavior where sensitivity is greatest while still gaining some resource benefit. It also has to be evaluated in the actual workload.
- The retailer's decision therefore has two tests. Does the service use less memory, time or energy as intended?
- And does it still produce outputs that meet the required quality, including difficult cases? Both operating behavior and task quality belong in the evidence.