1
$\begingroup$

Can someone explain to me what it means for floating point numbers to have "uneven" spacing on a number line? As I visualize this, all I see is evenly spacing out floating point numbers.

When I google for an explanation, most of them just say "floating point numbers have uneven spacing", but none of them explain why or how?

When I look at a ruler for example, everything is evenly spaced out so where does the "uneven" spacing thing come in and exactly mean visually?

  • 0
    It comes from binary gaps: see http://www.exploringbinary.com/the-spacing-of-decimal-floating-point-numbers/ for a reasonable explanation2017-01-11
  • 0
    I'm not quite sure what binary gaps are, I'm still new to this complicated business of numerical analysis.2017-01-11
  • 0
    A nontechnical analogy: Suppose you are writing numbers in scientific notation, $m\times10^n$, but you are only allowed to write one digit in $m$ and one digit in $n$. Then the numbers you can write are unevenly spaced: 1, 2, 3, ..., 8, 9, 10, 20, 30, ..., 80, 90, 100, 200, 300, ...2017-01-11
  • 0
    The ticks on a ruler correspond to **fixed** point numbers, not **floating** point. For pictures of floating point numbers, see here, for example: http://blogs.mathworks.com/cleve/2014/07/07/floating-point-numbers/.2017-01-12

3 Answers 3

2

The uneven spacing comes from the exponent. There are a fixed number of bits in the mantissa for a given storage format. For example, in IEEE $64$ bit storage there are $52$ bits for the mantissa, which says the LSB is $2^{-51}$ times the MSB. If the exponent is zero (after allowing for the offset) the difference between two neighboring floats will be $2^{-51}$. If the exponent is $20$, the difference between two neighboring floats will be $2^{-31}$ because the mantissa is multiplied by $2^{20}$. They are (approximately) separated by the same fractional amount, but by different absolute amounts.

  • 0
    Can you elaborate on what you mean by "which says the LSB is 2^-51 times the MSB"?2017-01-11
  • 0
    If the mantissa were four bits and the exponent zero, the number after $1.000_2$ would be $1.001_2$, which is $1+2^{-3}$ for a gap of $\frac 18$. The same works with $52$ bits and lots more zeros. Then if the exponent were $11_2=3_{10}$ we would have neighboring numbers be $1.000+2\cdot 2^3=8$ and $1.001_2 \cdot 2^3=9$ for a gap of $1$ instead of $\frac 18$2017-01-11
0

Floating point numbers are represented in the form $A \cdot 2^B$, where $A$ and $B$ are both integers. This means that the difference between a floating point number and the "next" (the one you get increasing $A$ by $1$) is $2^B$; thus the smaller $B$, the closer the spacing.

0

Since there is a constant number of mantissa bits, you have the same number of floating point numbers as in the interval from $1$ to $2$ also in the interval from $2$ to $4$ and from $4$ to $8$, and generally in any interval $[2^n, 2^{n+1})$. As the interval length increases, so does the spacing between the floating point numbers.