Quarry School

Read binary place values — quick review

In plain words

Picture a kitchen scale and four weights marked 8 grams, 4 grams, 2 grams and 1 gram.

Rule

This rule models one convention: a four-bit unsigned pattern with exactly four bits, columns worth 8, 4, 2 and 1 from left to right, and no sign. Other conventions read the leftmost bit as a plus or minus sign, so the answers here hold only when the pattern is stated to be unsigned.

To decode, the initial state is a total of 0 with your pencil at the 8 column. Move left to right, one column at a time. If the column holds 1, add its value to the total; if it holds 0, add nothing. Stop after the 1 column, and the total is the number.

To encode, the initial state is a remaining amount equal to the number, with four empty boxes under the headers 8 4 2 1. Move left to right, starting at the 8 column. If the column's value is no more than the remaining amount, write 1 and subtract the value; otherwise write 0. Stop after the 1 column. If the remaining amount is 0, the four marks are the pattern; if it is not 0, the number does not fit in four bits.

Step

  1. Write the headers 8 4 2 1 across your paper and draw a box under each.

  2. To decode, copy the pattern into the boxes, one digit per box. Check that there are four digits and that each is 0 or 1.

  3. Set the total to 0. Working left to right, add the header of every box that holds 1 and skip every box that holds 0.

  4. Stop after the 1 column. The total is your number.

  5. To encode, write the number as the remaining amount. Working left to right, ask whether the header is no more than the remaining amount.

  6. If it is, write 1 in that box and subtract the header from the remaining amount. If it is not, write 0.

  7. Stop after the 1 column. If the remaining amount is 0, read the four boxes as your pattern and keep any leading zeros. If it is not 0, the number does not fit in four bits.

  8. Check by running the rule the other way: decode the pattern you wrote, or encode the number you found, and compare with where you started.

Trap

If you read 1010 as one thousand and ten, you have used decimal columns, which step by ten: 1000, 100, 10 and 1. The same four marks then name a much larger number. Binary columns step by two, so 1010 in binary is 8 + 2 = 10.

Three habits guard against this. Write "in binary" next to the pattern, write the headers 8 4 2 1 above the digits before you read, and check that every digit is 0 or 1. A digit from 2 to 9 means the marks are not a binary pattern at all.