Binary numbers: introduction

This section forms a brief introduction to the binary number-system.

Binary numbers are closely linked to digital logic, because arithmetic on binary numbers can easily be implemented using an array of logic-gates.

This section doesn't go into binary arithmetic, since there's not much arithmetic going on in the Qibec CPU except "increment by one" to calculate the next program-address.

Decimal digits and numbers

Most everyday arithmetic (e.g. when buying goods in a store) makes use of the decimal number-system.

A decimal number consists of decimal digits. A decimal digit is a symbol from "0" up to and including "9". The reason for there being exactly 10 digits, is probably that humans have 10 fingers.

The value of a decimal number can be much higher than 10 (e.g. 15382), but the value of a digit is 9, at most.

Decimal digits form decimal numbers according to "decimal positional notation". This means that in a number, the position of a digit determines its magnitude.

As an example, consider the decimal number "345" (three-hundred and forty-five). The meaning, or value, of this number is:

345(dec)  =  3 x hundred  +  4 x ten  +  5 x one

or rather:

345(dec)  =  3 x 10^2  +  4 x 10^1  +  5 x 10^0

(The caret stands for "to the power of". The "dec" suffix is added to make it clear this is a decimal number - or in other words, make it clear how to interpret this number.)

As can be seen, the magnitude (or numeric weight) of a digit depends on its position: the further a digit is positioned to the left, the more it weighs.

This is very convenient: big numbers can be formed using a small set of symbols (0..9).

Bits and binary numbers

The decimal number-system is also called "base-10", because when going 1 digit to the left in a decimal number, its magnitude increases by a factor 10.

As stated before, this number "10" is arbitrary - if humans had had 12 fingers, we would probably be using a base-12 number-system.

The binary number-system narrows down the set of possible symbols from 10 to 2.

(The value of this binary symbol can only be "0" or "1". Such a binary symbol/digit is called a "bit" - literally "Binary digIT".)

Therefore, the binary number-system is a base-2 system. Like the decimal number-system, the position of a bit in a binary number determines its magnitude or weight:

1011(bin)  =  1 x 2^3  +  0 x 2^2  +  1 x 2^1  +  1 x 2^0

or, in words:

1011(bin)  =  1 x eight  +  0 x four  +  1 x two  +  1 x one

The value of this binary number is therefore eleven.

When mixing binary and decimal numbers, it becomes important to explicitly state the number-system that is to be used.

For example:

110(bin)  =  1 x four  +  1 x two  +  0 x one  =  six

but:

110(dec)  =  1 x hundred  +  1 x ten  +  0 x one  =  hundred-ten

Obviously, a big difference. Sometimes, a "b" suffix is used for binary numbers, e.g. "110b".

Relevance of binary numbers to computing

For a few reasons, binary numbers and binary/digital arithmetic lend themselves better to electrical implementations than do decimal numbers.

For one, the water- and electrical circuits given earlier make use of only 2 pressure-/voltage-states: either high or low.

From a practical point, this is convenient, because it presents less ambiguity between values.

(Compare this to a model with e.g. 10 different pressure-levels. More advanced components would have to be used to distinguish levels, and there's a risk of pressure/voltage dropping too much when traveling in a long pipe/wire.)

Circuits to perform binary arithmetic can be implemented one bit at a time, by using sub-circuits. For example, adding 2 binary numbers of 10 bits each can be done by 10 cascaded subcircuits, each adding 2 bits at a certain position.

Without going into detail, this method of addition is very similar to how most people perform addition: write the numbers to be added under each other, then, for each digit-position from right to left, add the digts, "carrying" a digit to the left if a sum exceeds 9.

 carried :     1               1111

number A :     44              0101100
number B :     28              0011100
              ---- +(dec)     --------- +(bin)
  result :     72              1001000

Using the same method, the only difference between adding decimal and binary numbers is that when using binary numbers, a digit has to be carried to the left if a result exceeds 1 instead of 9.

Thus, by using many simple subcircuits together, binary arithmetic can be implemented - addition just being an example.