Machine numbers.

The set of numbers which can be expressed in the form

(mantissa) x 2^(exponent) 

where mantissa and exponent have a specified number of binary digits, are called the "machine numbers" (for the given number of digits). In a computer, the number of bits required for exponent and mantissa (+1 for sign) is the size of the floating point number.

We plot the set of machine numbers with a different number of bits for the exponent and mantissa. We first consider the case where the numbers are not normalized:

nMantissa = 3;
nExponent = 2;

Now a number with nExponent binary digits has to be positive (in computer science, we’d call this an “unsigned” integer type). To convert it to a signed number, we subtract the number 01111..1, with a total of nExponent digits, from our original exponent. This number is 2^(nExponent-1) (or 10000...0) - 1. This makes the range of numbers represented by the nExponent bits centered at zero.

TotalBits = nMantissa + nExponent + 1
findExp[x_] := x - ((2^(nExponent-1))- 1);

For now, the mantissa is just going to be positive. So the set of numbers represented by nMantissa bits is simply the set  of numbers from 0 to 2^(nMantissa) - 1.

We now make a table of machine numbers which can be represented in this format with the given number of bits.

MachNumbers1 = Table[((n) /(2^(nMantissa)))*2^(findExp[r]),{n,0,2^nMantissa-1},{r,0,2^nExponent-1}];
Sort[Flatten[MachNumbers1]]
Length[Union[Flatten[MachNumbers1]]]

We now plot these numbers:

ListPlot[Partition[Riffle[Flatten[MachNumbers1],Flatten[Table[0,{n,0,2^nMantissa-1},{r,0,2^nExponent-1}]]],2],PlotStyle-> {PointSize[Large]}]

If we require NORMALIZED floating point numbers, then each mantissa has to start with 1 in binary, and we might as well not store the 1 since we know it’s always going to be there. If we work out the details, this is the same as adding 2^(nMantissa) (10...0 in binary) to the set of nMantissa digit binary numbers and then dividing by 2^(nMantissa + 1), since the normalized mantissas essentially have 1 more digit than the unnormalized mantissas.

NormalizedMachNumbers = Table[((n + 2^nMantissa) /(2^(nMantissa+1)))*2^(findExp[r]),{n,0,2^nMantissa-1},{r,0,2^nExponent-1}];

Sort[Flatten[NormalizedMachNumbers]]
Length[Flatten[NormalizedMachNumbers]]

Here’s the resulting plot of normalized machine numbers.

ListPlot[Partition[Riffle[Flatten[NormalizedMachNumbers],Flatten[Table[0,{n,0,2^nMantissa-1},{r,0,2^nExponent-1}]]],2],PlotStyle-> {PointSize[Large]}]

There are a couple of things to notice here: first, does anything look funny on the left hand side of the plot? Second, notice that there are MORE numbers here.

Theorem: Unlike the standard representation of floating point numbers, the normalized representation of a floating point number is always unique. 
Extra credit: Prove it!