Basis Lab

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.

FIG 1
exponent fieldfraction fieldwhat the pattern reads asan example
all 11 bits zerozeroa zero, and the sign bit still means something0000000000000000
all 11 bits zeronot zeroa subnormal, leading bit 0, exponent pinned at minus 1,0220000000000000001
1 to 2,046anythingan ordinary value, leading bit 1, exponent minus 1,0233ff0000000000000
all 11 bits onezeroan infinity, with its sign7ff0000000000000
all 11 bits onenot zeronot a number7ff8000000000000

The fraction field has 252−12^{52} - 1 non-zero settings, so

2×(252−1)=9,007,199,254,740,9902 \times (2^{52} - 1) = 9{,}007{,}199{,}254{,}740{,}990 of the 2642^{64}

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 contents

This 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

The rest of this course

  1. 01Why Eight Bits Hold 256 Values and Minus 128 Has No Positive Twin
  2. 02What Really Happens When a Sum Does Not Fitopening only
  3. 03Reading a Real Number Out of Its Bits, and Writing One Tenth Back Inopening only
  4. 04The Gap to the Next Representable Number, and How to Compute Itopening only
  5. 05One Rounding Is Half a Gap, and a Tenth Plus Two Tenths Is Exactly a Tieopening only
  6. 06Error in a Long Sum Grows Like Root n, Not Like nopening only
  7. 07The Subtraction That Loses Every Correct Digit at Onceopening only
  8. 08Two Zeros, Two Infinities, and a Value Not Equal to Itselfyou are here

Read alongside