Number Systems

Number Systems

Digits for common number systems :

Binary : 0 1

Octal : 0 1 2 3 4 5 6 7

Decimal : 0 1 2 3 4 5 6 7 8 9

Hexadecimal : 0 1 2 3 4 5 6 7 8 9 A B C D E F

Counting is always same (obviously), but representation changes because of digits used. E.g., counting to 20 (B - Binary, O - Octal, D - Decimal, H - Hexadecimal) :

        B    O    D    H
       --   --   --   --
        0    0    0    0
        1    1    1    1
       10    2    2    2
       11    3    3    3
      100    4    4    4
      101    5    5    5
      110    6    6    6
      111    7    7    7
     1000   10    8    8
     1001   11    9    9
     1010   12   10    A
     1011   13   11    B
     1100   14   12    C
     1101   15   13    D
     1110   16   14    E
     1111   17   15    F
    10000   20   16   10
    10001   21   17   11
    10010   22   18   12
    10011   23   19   13
    10100   24   20   14
Binary 10 is decimal 2, because only 2 objects use all available digits. Similarly, octal 10 is decimal 8. Hexadecimal includes 16 digits (Hex meaning 6, dec meaning 10, 10 + 6 = 16 (decimal)), so hexadecimal 10 is decimal 16.

Conversion among systems is thus simple (though not always quick). For the rest of the discussion, subscripts b, o, and h are used for non-decimal numbers (as shown above). E.g., convert 8236 to all others :

Binary : 213 = 8192. Note from above that 10b = 21, 100b = 22, etc. So

  213 = 10000000000000b (13 0's).

Next calculate the remainder :

  8236 - 8192 = 44 .

  25 = 32, which is 100000b (5 0's).

Calculate the remainder :

  44 - 32 = 12 .

  23 = 8, which is 1000b .

Calculate remainder :

  12 - 8 = 4 .

  22 = 4, which is 100b .

No remainder - done ! Digits were found for the 14th, 6th, 4th, and 3rd positions. Thus,

    10000000000000b
            100000b
              1000b
    +          100b
    --------------
    10000000101100b
Octal : I use the same procedure, but without explanations :
  84 = 4096.  4096 × 2 = 8192, which is 20000o .

  8236 - 8192 = 44,  81 = 8.  8 × 5 = 40, which is 50o .

  44 - 40 = 4, which is 4o .

    20000o
       50o
    +   4o
    -----
    20054o
Note that an extra step was required for determining each digit because more than 1 non-zero digits exist for every number system except binary.

This calculation could be much easier because the binary equivalent was already determined. Because both are powers of 2, the binary representation can be written :

  10 000 000 101 100 b
Because 23 = 8, each group of 3 binary digits is an octal digit. From the counting example above, note :
 10 000 000 101 100 b = 2 0 0 5 4 o
Hexadecimal. We can use the original technique illustrated :
  163 = 4096.  4096 × 2 = 8192, which is 2000h .

  8236 - 8192 = 44.  161 = 16.  16 ×  2 = 32, which is 20h .

  44 - 32 = 12, which is Ch .

    2000h
      20h
    +  Ch
    ----
    202Ch
Or because binary representation is known, the latter one :
  10 0000 0010 1100 b = 2 0 2 C h
Thus,
8236 = 10000000101100b = 20054o = 202Ch .
Mathematical calculations using each system are same, only interpretation of numbers different. E.g., consider 7 × 7 = 49 for binary numbers. 7 = 111b, thus :
          1 1 1 b
        × 1 1 1 b
         -------
          1 1 1 b
        1 1 1 0 b
      1 1 1 0 0 b
    ------------
    1 1 0 0 0 1 b

    1 1 0 0 0 1 b = 32 + 16 + 0 + 0 + 0 + 1 = 49
The addition part may become a little complicated for people unaccustomed with this, because 'carrying' 2 (required twice) means 'carrying' 10b, etc.

Consider 9 × 7 = 63 for octal numbers. 9 = 11o, thus :

   1 1 o
   × 7 o
   ---
   7 7 o

   7 7 o = 56 + 7 = 63
Note that multiplication is exactly the same as for decimal numbers, but we cannot say for octals that 7o × 7o = 49o, because no 9o exists. 7o × 7o = 61o - part of the octal multiplication tables (same idea as 9 × 9 = 81) !

Which system is best ? That's a difficult question. Scientific notation is commonly used for very large numbers, a problem which hexadecimal or perhaps even base 32 or 64 would help solve. The English alphabet contains 26 letters, so perhaps such is reasonable. That's not the whole story though. As hinted above, base 64 would require enormous multiplication tables, 632 - 63 = 3906 values !, which are required for common math operations. Hexadecimal requires 162 - 16 = 240, more reasonable, though different characters should be used for A-F. A person may be tempted to say octal is best, because most numbers we deal with are not large. Then temps of > 100o °F (64 °F) would be much more common (if 0 °F remained same). Or you can change the temperature scale so that 100° remains hot


Text is copyright of Joseph Bartlo, though may be used with proper crediting.

Home Page