University of Bahrain, IT College, CS Department
Course: CSC103
                                           Numbering Systems
     1. Numbering Bases
          -    Base 2: binary base, where the digits are 0, 1
          -    Base 8: octal base, where the digits are 0, 1, 2, 3, 4, 5, 6, 7
          -    Base 10: decimal base, where the digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
          -    Base 16: hexadecimal base, where the digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
         ➢ An octal digit has a perfect correspondence to a 3-bit binary value number (8 = 23 )
                                         Base 8                Base 2
                                           0                    000
                                           1                    001
                                           2                    010
                                           3                    011                  Table 1
                                           4                    100
                                           5                    101
                                           6                    110
                                           7                    111
         ➢ A hexadecimal digit has a perfect correspondence to a 4-bit binary value number (16 = 24 )
                                        Base 16                Base 2
                                           0                    0000
                                           1                    0001
                                           2                    0010
                                           3                    0011
                                           4                    0100
                                           5                    0101
                                           6                    0110
                                           7                    0111                 Table 2
                                           8                    1000
                                           9                    1001
                                         A(10)                  1010
                                         B(11)                  1011
                                         C(12)                  1100
                                         D(13)                  1101
                                         E(14)                  1110
                                         F(15)                  1111
Prepared by: Dr. Youssef Harrath                                                                         1
University of Bahrain, IT College, CS Department
Course: CSC103
     2. Conversion between bases
          ➢ Binary(2) → Octal(8)
               Separate the binary number in groups of 3 digits each starting from the right side. Complete the most left
               group by zeros (in its left side) if it contains less than 3 digits. Convert each group of 3 digits into its
               corresponding octal digit (according to the table 1).
               Example
                                     (1011100101000)2 = (001 011 100 101 000)2 = (13450)8
          ➢ Binary(2) → Hexadecimal(16)
               Separate the binary number in groups of 4 digits each starting from the right side. Complete the most left
               group by zeros (in its left side) if it contains less than 4 digits. Convert each group of 4 digits into its
               corresponding hexadecimal digit (according to the table 2).
               Example
                                    (10110010011011)2 = (0010 1100 1001 1011)2 = (2𝐶9𝐵)16
          ➢ Base b(2, 8, or 16) → Decimal(10)
               Given a number 𝐴 in a base b (2, 8, or 16), A can be written as: (𝐴)𝑏 = (𝑎𝑛−1 𝑎𝑛−2 … 𝑎0 )𝑏 where
                0 ≤ 𝑎𝑖 ≤ 𝑏 − 1 and 0 ≤ 𝑖 ≤ 𝑛 − 1
               To convert the number A from a base b (b= 8, 10, or 16) to its equivalent decimal number, we use the
               following formula:
                                                                     𝑛−1
                                                             (𝐴)𝑏 = (∑ 𝑎𝑖 𝑏 𝑖 )10
                                                                      𝑖=0
               Example 1: Binary(2) → Decimal(10)
               (011101)2 = ((1 × 20 ) + (0 × 21 ) + (1 × 22 ) + (1 × 23 ) + (1 × 24 ) + (0 × 25 ))
                                                                                                  10
                              =( 1       +   0     +     4      +     8     +       16   +   0   )10
                              = (29)10
               Example 2: Octal(8) → Decimal(10)
               (1237)8 = ((7 × 80 ) + (3 × 81 ) + (2 × 82 ) + (1 × 83 ))10
                       =( 7         + 24        + 128 + 512 )10
                       = (671)10
               Example 3: Hexadecimal(16) → Decimal(10)
               (1𝐴𝐹2)16 = ((2 × 160 ) + (𝐹 × 161 ) + (𝐴 × 162 ) + (1 × 163 ))10
                        = ((2 × 160 ) + (15 × 161 ) + (10 × 162 ) + (1 × 163 ))10
                        =( 2          +    240      + 2560        + 4096 )10
                         = (6898)10
Prepared by: Dr. Youssef Harrath                                                                  2
University of Bahrain, IT College, CS Department
Course: CSC103
          ➢ Octal(8) or Hexadecimal(16) → Binary(2)
               Expansion of each digit into its binary equivalent 3-binary digits for base 8 and 4-binary digits for base 16.
               Example 1: Octal(8) → Binary(2)
               (743)8 = (111 100 011)2
               Example 2: Hexadecimal(16) → Binary(2)
               (𝐴𝐹680)16 = (1010 1111 0110 1000 0000)2
          ➢ Decimal(10) → Binary(2)
                   - Successive divisions of the quotient by 2
                   - Stop when the quotient becomes 0
                   - Copy the reminders starting from the last division
               Example
               (756)10 = (? )2
               756 = 378 × 2 + 𝟎
               378 = 189 × 2 + 𝟎
               189 = 94 × 2 + 𝟏
                94 = 47 × 2 + 𝟎
                47 = 23 × 2 + 𝟏
                23 = 11 × 2 + 𝟏
                11 = 5 × 2 + 𝟏
                 5= 2×2+𝟏
                 2= 1×2+𝟎
                 1= 𝟎×2+𝟏
               (756)10 = (1011110100)2
          ➢ More Conversions
              • Octal (8) → Hexadecimal (16)
                       Convert the octal number to binary and then from binary to hexadecimal.
                    Example:
                    (705)8 = (? )16
                    (705)8 = (111 000 101)2
                    (705)8 = (1 1100 0101)2
                    (705)8 = (0001 1100 0101)2
                    (705)8 = (1𝐶5)16
Prepared by: Dr. Youssef Harrath                                                                      3
University of Bahrain, IT College, CS Department
Course: CSC103
                    • Hexadecimal (16) → Octal (8)
               Convert the hexadecimal number to binary and then from binary to octal.
               Example:
                    (𝐷𝐹162)16      = (? )8
                    (𝐷𝐹162)16      = (1101 1111 0001 0110 0010)2
                    (𝐷𝐹162)16      = (11 011 111 000 101 100 010)2
                    (𝐷𝐹162)16      = (011 011 111 000 101 100 010)2
                    (𝐷𝐹162)16      = (3370542)8
                    • Decimal (10) → Octal (8)
               Convert the decimal number to binary and then from binary to octal.
               Example:
                    (756)10    = (? )8
                    (756)10    = (1011110100)2
                    (756)10    = (1 011 110 100)2
                    (756)10    = (001 011 110 100)2
                    (756)10    = (1364)8
                    • Decimal (10) → Hexadecimal
               Convert the decimal number to binary and then from binary to hexadecimal.
               Example:
                    (756)10    = (? )16
                    (756)10    = (1011110100)2
                    (756)10    = (10 1111 0100)2
                    (756)10    = (0010 1111 0100)2
                    (756)10    = (2𝐹4)16
     3. Binary addition and multiplication
          ➢ Addition
               We use the following table to perform addition in base 2.
                                                 1 + 1 = 0 and reminder 1
                                                 1+0=1
                                                 0+1=1
                                                 0+0=0
Prepared by: Dr. Youssef Harrath                                                           4
University of Bahrain, IT College, CS Department
Course: CSC103
               Example 1
                                                             1 0 1 1 0
                                               +
                                                             0 1 1 1 1
                                                      = 10 0 1 0 1
               Example 2
                                                              0 1 1 1 0 1
                                               +
                                                              0 1 0 0 0 1
                                                         =    1 0 1 1 1 0
          ➢ Multiplication
               We use the following table to perform multiplication in base 2.
                                                          1×1=1
                                                          1×0=0
                                                          0×1=0
                                                          0×0=0
               Example
                                                                            1 0 1
                                               ×
                                                                            0 1 1
                                                                           1 0 1
                                                                         1 0 1
                                                                       0 0 0
                                                                 =     0 1 1 1 1
     4. Exercises
          A. Convert the following numbers to the indicated base (show your steps)
                 a. (0111001)2 = (? )10
                 b. (𝐹𝐸30)16 = (? )10
                 c. (1764)8 = (? )2
                 d. (0111001)2 = (? )8
                 e. (3908)10 = (? )16
          B. Find the binary sum and product of the following two binary numbers:
             0111001 and 011
Prepared by: Dr. Youssef Harrath                                                     5