AI Ecosystem CourseLearn with Q
Compute Fundamentals · Lesson 4

Bits, Bytes And AI Number Precision

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.

Study And Save Progress

Watch The Lesson

10 min 40 sec

Read the video transcript

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? Lesson four: Bits, bytes, and numerical precision. By the end, you should be able to calculate a simple storage payload, separate numerical range from precision, and explain why two sixteen-bit formats can behave differently.

We'll follow three steps. First, count bits and bytes. Second, look at what a format can represent. Third, weigh possible savings against numerical behavior and the quality of the retailer's result. The guiding question is: what changes when the same task uses a different representation for its numbers? 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. Let's make the scale concrete with 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. In Lesson five, we'll examine a specific way of using compact values and why its actual footprint can exceed the raw payload. For now, the byte count tells us why representation matters for what fits and how much data may need to move. 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. That is an analogy for losing detail, not a literal model of computer floating point. Actual floating-point formats use binary patterns with more structure than rounding ordinary decimal numbers to a fixed place. 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? 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 minus three point two times ten to the fourth, the minus sign tells direction, the fourth power tells scale, and three point two carries the meaningful 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. Lesson five will examine quantization in detail. Here, keep the principle: the label and bit count are the start of the comparison, not the conclusion. Return to 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. Why should FP16 and BF16 not be treated as identical just because both occupy sixteen bits? They allocate their bits differently. Their exponent and fraction choices give different range and precision properties. Both use two bytes per value in the nominal count, but equal size does not imply equal numerical behavior.

The task's values and quality requirements tell us which differences matter. One short storage check. How many bytes of numerical payload do one million thirty-two-bit values occupy? What is the nominal payload at sixteen bits? Thirty-two bits are four bytes, so one million values occupy four million bytes of payload. Sixteen bits are two bytes, giving two million bytes. Those totals describe the values alone, not all the memory a running model or service needs. We counted bits into bytes, then separated storage size from numerical behavior.

Range concerns the magnitudes a format can handle; precision concerns distinguishable detail. Floating-point formats allocate bits to sign, scale and meaningful digits. FP16 and BF16 share a bit count but make different allocation choices. Smaller representations can save memory and movement, and supported hardware can benefit. Rounding, overflow, underflow, accumulated error and sensitive computations can change results. Measure the physical gain and check the retailer's actual task quality before calling the change successful. In Lesson five, we'll examine quantization: a specific way to map values into a smaller set of levels. We'll see why “four-bit” alone does not describe a complete deployment or guarantee a speedup.

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

1. The Representation Decision

Format SizeBytes Per ValuePayload For 1 Million Values
32 bits44,000,000 bytes
16 bits22,000,000 bytes
8 bits11,000,000 bytes
4 bits, ideal packing0.5500,000 bytes

Boundary: Numerical payload only. Packing, metadata and runtime state add requirements.

2. Bits, Bytes, and Nominal Payload

3. Range, Precision, and Lost Detail

4. Floating-Point Roles and Format Choices

5. Resource Gains and Numerical Consequences

Check Your Understanding

Check Your Understanding

Write your answer, compare it with the model answer and decide what to revisit. These written checkpoints are self-assessed.

Why should FP16 and BF16 not be treated as identical just because both occupy sixteen bits?

Show The Model Answer

They allocate their bits differently. Their exponent and fraction choices give different range and precision properties. Both use two bytes per value in the nominal count, but equal size does not imply equal numerical behavior. The task's values and quality requirements tell us which differences matter.

Compare your reasoning with the worked explanation in the reading. This is a written self-check.

How many bytes of numerical payload do one million thirty-two-bit values occupy? What is the nominal payload at sixteen bits?

Show The Model Answer

Thirty-two bits are four bytes, so one million values occupy four million bytes of payload. Sixteen bits are two bytes, giving two million bytes. Those totals describe the values alone, not all the memory a running model or service needs.

Compare your reasoning with the worked explanation in the reading. This is a written self-check.

Open Practice And Save Your Work