# What is meant by “uneven spacing” on number line when dealing with floating point numbers in computers?

I read some examples online on this subject, but none of them really gave an explanation. When I visualize the number line all I can see is evenly spaced numbers, I'm not grasping the notation of "uneven spacing" when It comes to plotting the floating point values from a machine's perspective. Perhaps I am thinking about this too literally.

Let's look at a single-precision floating point number (as specified by IEEE 754). It is made up of 32 bits. Therefore, there are exactly $2^{32}$ floating point numbers that dots the number line.

What does it mean when we say that the floating point numbers are "unevenly" distributed on the number line? It means that they are not uniformly distributed. But why?

Well, let's consider the case where these numbers are distributed uniformly on the number line. Then there's some constant finite gap between successive numbers, $\Delta$. Since there are $2^{32}$ points on this line, then these uniformly distributed numbers span an interval of $\Delta \times 2^{32}$ width.

How big is $2^{32}$? Well, it's about 4 billion. Do you see the problem with uniformly distributed representations of numbers? If you want to even be able to represent the number $\pm 2$ billion in your uniform system, then you need to make sure that both $-2 \times 10^9$ and $2 \times 10^9$ are within your representable interval. Therefore, we need $\Delta \times 2^{32} \ge 4 \times 10^9$, so that we must space our numbers around $\Delta \approx 1$ apart. But if $\Delta \approx 1$, how are you going to represent both $1$ and $0.5$ precisely? Their difference is smaller than the gap!

Herein lies the rationale for having non-uniformly distributed representations such as floating point numbers. Uniformly distributed representations (or fixed-point numbers) cannot represent both big numbers and small numbers in a "good-enough" manner.

Positive floating point numbers are encoded as something like

$Mantissa * 2^{Exponent-Constant}.$

Where $Mantissa$ and $Exponent$ are naturals, for example respectively 24bits and 7bits scalars (32bits single precision).

The 'spacing' between consecutive values depend on the exponent, it is not constant.

(Actual floating point numbers are a bit more complex with encoding for infinites, tricks around zero...)