Availit World How AI really works, in your language

Lesson 8 of 4615 minFacts checked October 20, 2026

Bits and floats: how computers store numbers

A model is billions of numbers, and the number of bits each one gets decides how big the file is, how fast it runs and how far it can be squeezed. After this lesson, “BF16”, “FP8” and “MXFP4” will mean something.

In this lesson you will

  • Count in binary, and say how many different values a number of bits can hold
  • Read a floating-point number as a sign, an exponent and a fraction
  • Compare FP32, FP16, BF16, FP8 and FP4, and say why AI keeps moving to fewer bits
  • Explain how blocks of weights share a scale, and work out a model’s size from its format
On this page
  1. Everything is bits
  2. Floating point: scientific notation in binary
  3. The formats AI uses
  4. Sharing a scale: how 4 bits can be enough
  5. From bits to gigabytes
  6. Remember
  7. Check yourself

Everything is bits

Computers store everything as bits: tiny switches that are either 0 or 1. One bit can tell two things apart. Two bits give four patterns (00, 01, 10, 11). Every extra bit doubles the number of patterns.

How many different values fit in a number of bits
BitsDifferent valuesExample
12yes or no
416the 4-bit weights of a squeezed model
8 (one byte)256one letter of English text
1665,536the weights of most released models
32about 4.3 billionthe numbers in most ordinary software

Eight bits make a byte, the unit for file sizes. A gigabyte (GB) is a billion bytes. That gives the most useful rule in this course: a model’s size in bytes is its number of weights times the bits per weight, divided by 8.

Floating point: scientific notation in binary

Whole numbers are easy to store, but model weights are numbers like 0.0213 or −1.7. For these, computers use floating point, the same idea as scientific notation. Light travels about 3.0 × 10⁸ metres per second: one part gives the digits (3.0), the other says where the decimal point goes (10⁸). That lets the same few digits describe both huge and tiny numbers.

A floating-point number splits its bits into three parts:

  • Sign (1 bit): plus or minus.
  • Exponent: the power of 2, which sets how big or small the number is. More exponent bits mean a wider range.
  • Fraction (also called the mantissa): the digits. More fraction bits mean more precision, so less rounding.
value = ± 1.fraction × 2^(exponent − bias)

The bias is a fixed number that lets the exponent go negative, for very small values.

−2.5 = − 1.25 × 2¹

Sign minus, exponent 1, fraction .25 (in binary .01).

A surprising result: floating-point numbers are not evenly spaced. There are as many of them between 1 and 2 as between 1,024 and 2,048. Near zero they are packed very tightly; for big numbers the gaps are wide. That suits neural networks well, because most weights are small numbers close to zero.

Try itStore a number five ways

Type any number, or pick one, and see what each format actually stores, the rounding error, and the bits themselves. Try 70000 (too big for FP16), 0.1 (no format stores it exactly) and 1000 (too big for FP8).

This interactive part needs JavaScript.

The formats AI uses

Floating-point formats you will see in model cards
FormatBits: sign, exponent, fractionLargest valueUsed for
FP321 + 8 + 23 = 32about 3.4 × 10³⁸Ordinary software; sums inside training that need extra care
FP161 + 5 + 10 = 1665,504Older GPUs. Precise, but its small range overflows easily
BF161 + 8 + 7 = 16about 3.4 × 10³⁸The standard for training and for releasing weights today
FP8 E4M31 + 4 + 3 = 8448DeepSeek-V3 was trained in it; DeepSeek-V4 and GLM-5.3 release weights in it
FP4 E2M11 + 2 + 1 = 46Only 15 different values; usable for weights when blocks share a scale

BF16 (“brain float”, from Google Brain) is the clever one. It keeps FP32’s 8 exponent bits, so it has the same huge range, and gives up fraction bits instead. Training rarely needs 7 exact digits, but it hates numbers that suddenly overflow to infinity. FP16 has the opposite trade-off, which is why training in FP16 needed tricks to keep numbers in range, and why BF16 replaced it.

Why keep cutting bits? Three reasons, and you already know two. Fewer bits mean a smaller file and less memory to read for every token, so text comes out faster. And GPUs do more sums per second with smaller numbers: on Nvidia’s H100, FP8 maths runs about twice as fast as BF16.

Quick check

Why did BF16 replace FP16 for training?

Show the answer

Answer: It has the same wide range as FP32, so numbers rarely overflow Both use 16 bits. BF16 spends 8 of them on the exponent, like FP32, so it can hold very large and very small values; FP16’s largest value is only 65,504.

Sharing a scale: how 4 bits can be enough

FP4 has only 15 values: 0, ±0.5, ±1, ±1.5, ±2, ±3, ±4 and ±6. Real weights are numbers like 0.0213. How can that possibly work? With one trick that runs through all of model compression: blocks that share a scale.

  1. Cut the weights into small blocks, for example 32 weights in a row.
  2. For each block, store one scale: a number that the whole block is multiplied by.
  3. Store each weight as a tiny number (4 bits) that, times the scale, comes close to the real weight.
  4. Because weights next to each other tend to have similar sizes, one scale fits the whole block well.
Real block formats
FormatBlockBits per weight
MXFP432 FP4 values + one 8-bit power-of-two scale4 + 8 ÷ 32 = 4.25
Q4_0 (llama.cpp)32 four-bit whole numbers + one 16-bit scale4 + 16 ÷ 32 = 4.5
Q8_0 (llama.cpp)32 eight-bit whole numbers + one 16-bit scale8 + 16 ÷ 32 = 8.5

That is why you see sizes like 4.25 or 8.5 bits per weight: the scale’s bits are shared out across the block.

OpenAI released gpt-oss with its expert weights in MXFP4, so the 20.9-billion-parameter model is a 12.1 GB file. That works out at about 4.6 bits per weight overall, because the attention weights and embeddings are kept at higher precision. Moonshot went further with Kimi K3: it taught the model to cope with MXFP4 during its later training stages (this is called quantization-aware training), so the 4-bit weights are the native release, not a squeezed copy. The quantization lesson in part 6 goes much deeper.

From bits to gigabytes

Size of a model file
bytes = parameters × bits per weight ÷ 8
8 billion × 16 ÷ 8 = 16 GB

Llama 3.1 8B in BF16.

8 billion × 8.5 ÷ 8 = 8.5 GB

The same model in Q8_0.

8 billion × 4.5 ÷ 8 = 4.5 GB

In Q4_0: small enough for most laptops.

1.6 trillion × 8 ÷ 8 = 1.6 TB

DeepSeek-V4-Pro in FP8: far too big for a laptop, so data centres spread it across many GPUs.

FP16’s largest value is 65,504. Which of these numbers can it store?

0 of 6 sorted
  • 1,000

    Answer: Fits in FP16

  • 70,000

    Answer: Too big

  • 0.5

    Answer: Fits in FP16

  • 65,000

    Answer: Fits in FP16

  • 1,000,000

    Answer: Too big

  • −3.75

    Answer: Fits in FP16

Remember

  • n bits hold 2ⁿ different values: 4 bits give 16, 8 bits (a byte) 256, 16 bits 65,536.
  • A floating-point number is a sign, an exponent (range) and a fraction (precision). Floats are packed tightly near zero.
  • BF16 is the standard for training and releases; FP8 is common for big models; FP4 works only with shared scales.
  • Block formats give a group of weights one shared scale: MXFP4 is 4.25 bits per weight, Q4_0 4.5, Q8_0 8.5.
  • Fewer bits: smaller files, less memory read per token, faster sums. Size = parameters × bits ÷ 8.

Words to know

Bit
The smallest unit of computer memory: a 0 or a 1.
Byte
8 bits. File and memory sizes are counted in bytes.
Floating point
A way to store numbers as a sign, an exponent and a fraction, like scientific notation in binary.
Exponent
The part of a float that sets its size, and so the format’s range.
Fraction (mantissa)
The part of a float that holds its digits, and so its precision.
BF16
A 16-bit float with the range of FP32 and less precision. The standard for model weights.
FP8
An 8-bit float. Used to train and release some of the largest models.
MXFP4
A block format: 32 four-bit floats sharing one scale, 4.25 bits per weight.
Mixed precision
Doing most of the work in few bits and the sensitive parts in more.
Overflow
A number too big for its format, which turns into infinity and breaks the calculation.

Go to the source

This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.

Check yourself

5 questions. Tap the answer you think is right.

0 of 5 answered

How many different values can 4 bits hold?

Show the answer

Answer: 16 Each bit doubles the count: 2 × 2 × 2 × 2 = 16.

In a floating-point number, what do the exponent bits control?

Show the answer

Answer: The range: how big or small the number can be The exponent is the power of 2, so it sets the scale. The fraction holds the digits, and the sign bit holds plus or minus.

A 70-billion-parameter model is stored in FP8. About how big is it?

Show the answer

Answer: 70 GB FP8 is 8 bits, one byte, per weight: 70 billion bytes, about 70 GB. In BF16 it would be 140 GB.

Why can MXFP4 work even though FP4 has only 15 values?

Show the answer

Answer: Each block of 32 weights shares a scale that the small values are multiplied by The shared scale moves the 15 values to the right size for each block, so each weight can be close to its true value.

Why does a model with fewer bits per weight write text faster?

Show the answer

Answer: Less data must be read from memory for each token Writing text is limited by memory bandwidth. Fewer bytes to read per token means more tokens per second.

Lesson complete

Answer every question above to complete this lesson.

Your progress is saved on this device only.

Next lessonMachine learning: letting data choose the numbers
Previous lesson All lessons

Choose your language