Last updated: Sunday 30th December 2017, 11:39 PT, AD

# 1.     Numbering Systems

Most people are used to the decimal system of numbering, which is based on ten numbers:

0,1,2,3,4,5,6,7,8,9

Let’s consider decimal numbers to remind ourselves how they work.

## 1.1     Decimal numbers

The number 125 (one hundred twenty five) represents one hundred and two tens and five ones.  Let’s show that another way:

Hundreds   Tens       Ones

1             2       5

1 x 100 = 100

2  x  10 =   20

5  x    1 =     5

-----

125

-----

If we look at a larger number, for example two thousand and thirty six (2036),  this number can be similarly represented:

Thousands    Hundreds    Tens    Ones

2                   0             3          6

2   x  1000  =  2000

0   x    100 =         0

3   x      10 =       30

6   x        1 =         6

------

2036

------

Notice that in decimal numbers, the right most digit represents the ones, the next represents the tens, the next the hundreds, then the thousands and so on.  In other words, starting at one, the others digits are multiplied by ten as you move over to the left, as the following series shows:

10000,  1000, 100, 10, 1

The binary system of numbering operates in exactly the same manner as the decimal system except that instead of having ten numbers, there are only two, and instead of multiplying by ten from right to left, numbers are multiplied by two.

### 1.1.1     Decimal - Base Ten

The following series of numbers illustrates base 10:

103         102         101         100

103    is verbalized as ten to the power of three,  and is calculated as 10 x 10 x 10  (1000).

102    is verbalized as ten to the power of two,  and is calculated as 10 x 10  (100).

101    is verbalized as ten to the power of one,  and is calculated as 10 x 1  (10).

Any value to the power of zero has a value of one:

100    is verbalized as ten to the power of zero,  and has a value of one.

## 1.2     Binary numbers

The binary numbering system is based on two numbers:

0 and 1

A binary number is also called a bit.  The word ‘bit’ is short for the two words ‘binary’ and ‘digit’.  There are only two bits, 0 and 1.

The three bit binary number 101 (verbalized as one zero one) represents the decimal number 5.  This is explained below:

Fours   Twos   Ones

1           0        1

1 x  4 =   4  (decimal)

0 x  2 =   0  (decimal)

1 x  1 =   1  (decimal)

-----

5  (decimal)

-----

If we look at a larger number, for example one zero one one (1011),  this number can be similarly represented:

Eights   Fours   Twos   Ones

1           0          1         1

1  x  8   =   8  (decimal)

0  x  4   =   0  (decimal)

1  x  2   =   2  (decimal)

1  x  1   =   1  (decimal)

-----

11 (decimal)

-----

A group of eight bits is known as a byte.  The following is an example of a byte which represents the decimal number 64:   01000000

A group of four bits (half a byte) is known as a nibble.  The following is an example of a nibble:  1010

The byte:      00000000   represents decimal 0

00000001   represents decimal 1

00000010   represents decimal 2

00000011   represents decimal 3

00000100   represents decimal 4

The largest binary number of a byte is 11111111.    This represents the decimal number 255.  Hence one byte can represent 256 decimal numbers, from 0, through 1 to 255.

Notice that in binary numbers,  the right most digit represents the ones,  the next represents the twos,  the next the fours,  then the eights and so on.   In other words,  starting at one,  the others digits are multiplied by two as you move over to the left,  as the following series shows:

16, 8, 4, 2, 1

The binary numbers are said to be to the base 2 as compared to decimal numbers which are base ten.

### 1.2.1     Binary - Base two

The following series of numbers illustrates base 2:

23      22      21      20

23    is verbalized as two to the power of three,  and is calculated as 2 x 2 x 2  (8).

22    is verbalized as two to the power of two,  and is calculated as 2 x 2  (4).

21    is verbalized as two to the power of one,  and is calculated as 2 x 1  (2).

Any value to the power of zero has a value of one:

20    is verbalized as two to the power of zero,  and has a value of one.

## 1.3     Octal Numbers

Because binary numbers are quite unwieldly, for instance seven digits are required to represent the decimal number 64, computer programmers often use the octal (base 8) or hexadecimal (base 16) numbering systems because they require fewer digits to represent the same decimal number.  The following sections show how the decimal number 64  (01000000 binary) is represented in the octal and hexadecimal systems.

Octal numbers only allow the digits 0 through 7.  The following table shows the octal numbering system and the equivalent decimal value.

82            81            80          (Decimal)

___________________________

(64)         (8)            (1)

0             0                     (0)

0             1                     (1)

0             2                     (2)

0             3                     (3)

0             4                     (4)

0             5                     (5)

0             6                     (6)

0             7                     (7)

1             0                     (8)

1             1                     (9)

1             0             0                     (64)        i.e.          1 x 64      +      0 x 8        +       0 x 1

The octal number which represents decimal 64 is 100.

Hexadecimal numbers only allow sixteen digits.  The digits 0 through 9 are used to represent the first ten digits.  The remaining six digits are represented by using the letters A to F.  The following table shows the hexadecimal numbering system and the equivalent decimal value.

162          161          160           (Decimal)

_____________________________

(256)     (16)            (1)

0             0                     (0)

0             1                     (1)

0             2                     (2)

0             3                     (3)

0             4                     (4)

0             5                     (5)

0             6                     (6)

0             7                     (7)

0             8                     (8)

0             9                     (9)

0             A                    (10)

0             B                    (11)

0             C                    (12)

0             D                    (13)

0             E                     (14)

0             F                     (15)

1             0                     (16)

1             1                     (17)

1             2                     (18)

1             3                     (19)

1             4                     (20)

4             0                     (64)

The hexadecimal number which represents decimal 64 is 40.

Although computers ultimately require all data in binary format, data supplied in octal or hexadecimal format is easily converted to binary by the computer because eight and sixteen are multiples of two.  The advantage for the programmer of using octal or hexadecimal numbers is that fewer digits are required.

```

```