Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Demo 1.1: What a Digit Is Worth

A digital circuit does not contain numbers. It contains voltages, and each of them is either near the supply or near ground, and that is all there is inside it. Everything else in this module, every adder and counter and register, works only because a group of those voltages has been agreed to mean a quantity.

That agreement is what this demonstration is about, and it is worth being explicit about it before anything is built on top of it. The agreement is called place weighting: each position in a number carries a fixed weight, the weights are powers of a chosen base, and a digit says how many of that weight you have.

The best way to see what an idea does for you is to look at what people managed without it. Roman numerals are not place weighted. An M is worth a thousand wherever it appears in the numeral, so the symbols do not have positions in any useful sense, and the number of marks you need grows with the size of the number rather than with its number of digits. Write 3888 in Roman and it takes fifteen symbols. Worse, the symbols are not independent of one another: IX and XI are made from the same two marks and mean different things purely because of their order, so you cannot work on one part of the numeral without looking at its neighbours. And there is no zero, because there is no column for anything to be absent from.

The consequence is interesting. Nobody has ever built an adder for Roman numerals, and nobody ever will, because adding two of them requires rules about which symbols may follow which rather than a carry. Place weighting is what makes arithmetic mechanical, and mechanical is the only kind of arithmetic a circuit can do.

Once you accept place weighting, the choice of base is almost an afterthought. Ten is not special, it is simply anatomical. Two is the one that suits a transistor, and octal and hexadecimal exist because eight bits written out in full are difficult for humans — try to communicate 10111010 to another human! (BA in hex is more likely to be communicated successfully.)

Place weights puts the four bases side by side. Above each digit is the weight of its position, below it is what that digit is actually contributing, and to the right is the running total in decimal. Set the digits with the arrows or by clicking them, then change the base without touching the digits and watch every weight change underneath the same pattern.

The odometer holds one byte, which is not an arbitrary limit. Eight bits, three octal digits, three decimal digits and two hexadecimal digits all reach at least 255, so the value survives any change of base and nothing you have set is ever lost. It is also the object the rest of the module is built out of.

There is a Roman numeral strip at the top of the same tab, with a count of how many symbols each system needs for the same quantity. It is short and it is the argument for everything below it.

Past the radix point carries the weights on to the right, where they become a half, a quarter and an eighth in binary, or a tenth and a hundredth in decimal. Changing base on this tab can lose something, and when it does the demonstration says so and tells you exactly what was lost. That is not a limitation of the widget. It is the point of the tab.

Place-Weighted Number Systems

What each position in a number is worth, on both sides of the point, in the four bases you will meet.

A digit is not a number. A digit and its position are. Every system below works the same way: each position carries a fixed weight, the weights are powers of the base, and a digit says how many of that weight you have. Change the base and every weight changes, so the same pattern of digits becomes a completely different quantity. Set the digits and watch the sum underneath them build up, then change the base without touching the digits.

What place weighting replaced
RomanMCMLXXXVII10 symbols
Decimal19874 symbols
Binary1111100001111 symbols
  • A Roman numeral has no places and therefore no weights.
  • An M is worth a thousand wherever it stands, so the number of symbols grows with the size of the number rather than with its number of digits.
  • Worse, the symbols are not independent of one another: IX and XI are built from the same two marks and differ only in their order.
  • And there is no zero, so there is no way to write "nothing here", because there is no "here" for anything to be nothing in.
Base
The whole number
27128
2664
2532
2416
16
238
8
224
212
2
201
=
26decimal
The expansion, in full

00011010 = (0×128) + (0×64) + (0×32) + (1×16) + (1×8) + (0×4) + (1×2) + (0×1) = 26₁₀

The same thing, without saying the zeros

16 + 8 + 2 = 26

That second line is how to read binary in practice: find the 1s, name their weights, add them up.

The same quantity, written four ways
Binary00011010yours
Octal32
Decimal26₁₀
Hexadecimal1A₁₆

Four strings of symbols, one quantity. Nothing about the number changed when the base did.

Base 2: Binary
  • Two symbols, 0 and 1. The largest is 1.
  • A transistor holds two states reliably and ten badly. That is the whole reason.
  • Each column is worth twice the one to its right.
  • Left-hand bit is the MSB, right-hand bit the LSB.
  • Eight bits make a byte: 0 to 255.
  • Read it by naming the weights above the 1s and adding.
  • No base has a symbol for itself: 10 means ten, eight or two depending on which you are in.

Step 1: Look at the Roman strip before anything else

Section titled “Step 1: Look at the Roman strip before anything else”

Open Place weights and try each of the four numbers along the top of the Roman strip.

Watch the symbol counts on the right. Decimal needs four symbols for 3888 and binary needs twelve, both of which grow slowly. Roman needs fifteen, and it needs them because there is no other way to say “three thousand” than to write M three times.

Now look at 1987, which comes out as MCMLXXXVII. The CM in the middle means nine hundred, and it means nine hundred only because the C is standing to the left of the M. Move it and you have a different number. There is no position in that numeral whose meaning can be worked out without looking at what is next to it, which is precisely the property that place weighting removes.

Step 2: Change the base without changing the digits

Section titled “Step 2: Change the base without changing the digits”

Set the base to Binary and leave the odometer at its starting value, 11010.

Read the expansion underneath. Every position is a power of two, the 1s contribute 16, 8 and 2, and the total is 26. Then read the second line, which drops the zeros: 16 + 8 + 2 = 26. That is how you should read binary in practice, and it is a great deal faster than eight multiplications.

Now press Octal, then Decimal, then Hexadecimal, without touching any digits.

The digits change, because the demonstration is holding the quantity and rewriting it. Twenty-six is 32 in octal, 26 in decimal and 1A in hexadecimal. Four strings of symbols, one number. Nothing about the quantity moved when the base did, in the same way that nothing about a distance changes when you write it in miles instead of kilometres.

While you are on each base, read the bullets on the right, which change with it. One rule underneath all four is worth having in your own words: a base with b symbols uses exactly b of them, from 0 to b minus 1, so the largest symbol is always one less than the base and no system has a symbol for its own base. Ten is written 10 in decimal, eight is written 10 in octal, and two is written 10 in binary. The moment you need the base itself, you have run out of symbols and started a new column.

Set the base back to Binary, press Reset, then press + 1 six times.

The value goes from 26 to 32, and on the way it passes through 31, which is 11111. Watch what the next press does. Five 1s become five 0s and a new 1 appears one position to the left, because the five weights 16, 8, 4, 2 and 1 add up to exactly one less than the weight above them.

That is a carry, and it is the whole reason binary arithmetic can be built out of gates. The rule is the same in every base, and it is the same rule you use in decimal when 99 becomes 100. When you meet the adders demonstration later, the ripple you will see propagating along a row of full adders is this, in hardware.

Open Past the radix point and load 101.011₂.

Nothing new has happened. The weights to the left of the point are 4, 2 and 1 as before, and the weights to the right carry on the same pattern downwards: a half, a quarter, an eighth. The expansion reads 4 + 1 + 0.25 + 0.125, which is 5.375.

The new thing on this tab is the mark itself. It is called a radix point rather than a decimal point, because it is a decimal point only when the base happens to be ten. In binary it separates the weight 1 from the weight one half, and that is the one position in any number whose weight you know without counting.

Now load 245.37₈ and then B7.8₁₆. Both are numbers from the reading, and both behave exactly the same way. One method, four bases.

Step 5: Find the number that binary cannot hold

Section titled “Step 5: Find the number that binary cannot hold”

This is the step to slow down for. Load 0.1₁₀, then press Binary.

The demonstration tells you that a tenth has no exact form in binary, however many bits you are willing to spend, and it shows you what it has done instead: it is holding 0.099853515625, which is the nearest twelve-bit value below a tenth.

The reason is arithmetic rather than engineering. A fraction terminates in base b only when its denominator is built out of the prime factors of b. Ten is 2 × 5, so halves and fifths both terminate in decimal. Two has only the factor 2, so a half terminates in binary and a fifth cannot, ever.

Look at the table of the same quantity in every base while you are here. The bar over a group of digits means that group repeats for ever, and a tenth recurs in binary, octal and hexadecimal alike. Binary, octal and hexadecimal never do this to one another, because 8 and 16 are powers of 2, so a fraction that terminates in one of them terminates in all three. Decimal is the outsider, and only in one direction: every binary fraction has an exact decimal form, and most decimal fractions have no binary one.

Step 6: Confirm that the other three get on perfectly well

Section titled “Step 6: Confirm that the other three get on perfectly well”

Load B7.8₁₆ and press Octal, then Binary, then back to Hexadecimal.

No warning appears at any point, and the value never changes. Powers of two convert between one another exactly, in both directions, for ever. Keep that fact in mind, because the next demonstration is largely about exploiting it.

Quiz
Select 0/1

What makes a system of numeration place weighted?

Quiz
Select 0/1

Reading the odometer in the demonstration, the binary number 11010 comes to 26. Which weights are being added?

Concept Match

Match each idea to what it actually does

Quiz
Select 0/1

Why can a tenth not be written exactly in binary?

Quiz
Select 0/1

You set the odometer to a value in hexadecimal, switch to octal, then switch back. What happens to the value?

Four things to carry into the rest of the module.

  1. A digit on its own means nothing. A digit and its column mean a quantity, and the column’s weight is a power of the base. That single sentence is the whole of numeration.
  2. A base is a way of writing a number down, not a property of the number. The same quantity in binary, octal, decimal and hexadecimal is the same quantity, and a circuit that counts to twenty-six is doing one thing however you choose to write it.
  3. The rule does not stop at the radix point. To the right of it the exponents simply go negative, and everything else is unchanged.
  4. Some perfectly ordinary numbers have no exact binary form. A tenth is one of them, and this is a fact about factors of 2 and 5 rather than a shortcoming of any particular machine.

The one thing this demonstration deliberately leaves out is negative numbers. There is no minus sign anywhere on it, because a circuit has no minus sign either: it has bits, and a sign has to be built out of them like everything else. Two’s complement is the usual answer and it gets a demonstration of its own.

The next demonstration takes the four bases here and asks how to move between them.