What a Computer Does to a Number
Two Zeros, Two Infinities, and a Value Not Equal to Itself
Last timeSubtracting Two Numbers That Are Nearly Equal
Where the signed zeros, the infinities, the not-a-number values and the subnormals come from, what every comparison does with them, and what a sort and a lookup table do when one arrives.
The 64 bit form has 11 exponent bits, which is 2,048 codes, and only 2,046 of
them are used for ordinary values. The two left over are the whole subject of
this page: the all-zero code holds the zeros and the values too small to
normalise, and the all-ones code holds the infinities and the values that are
not numbers at all. Each of them is a pattern the layout already had spare,
given a meaning so that every operation has an answer.
The five classes of bit pattern
Reading a 64 bit pattern starts at the exponent field, because two of its values
change the rule for everything after them.
| exponent field | fraction field | what the pattern reads as | an example |
|---|---|---|---|
| all 11 bits zero | zero | a zero, and the sign bit still means something | 0000000000000000 |
| all 11 bits zero | not zero | a subnormal, leading bit 0, exponent pinned at minus 1,022 | 0000000000000001 |
| 1 to 2,046 | anything | an ordinary value, leading bit 1, exponent minus 1,023 | 3ff0000000000000 |
| all 11 bits one | zero | an infinity, with its sign | 7ff0000000000000 |
| all 11 bits one | not zero | not a number | 7ff8000000000000 |
The fraction field has non-zero settings, so
of the
patterns are not-a-numbers, just under one in 2,048, with the same count again
of subnormals.
The lesson stops here
11 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents