ASCL Topic

Computer Number Systems

binary - octal - decimal - hexadecimal

All computers do the amazing things that they do by simply manipulating ones and zeros. Computers can only do binary (base 2) arithmetic. You must be able to use the binary number system in order to appreciate how the computer works. Since the computer works with the binary number system and since it is relatively easy to convert hexadecimal (base 16) and octal numbers (base 8) into binary, computer scientists need to be familiar with the octal and hexadecimal number systems.

I. Numbering Systems

  1. Decimal System
  2. Binary System
  3. Octal System
  4. Hexadecimal System

II. To convert a number in a base other than 10 to base 10

  1. Easy way: If you need to convert 345 (base 8) to decimal, you would label the three columns as the 1's, 8's, and 64's columns from right to left. Then, you would multiply the digits by these column labels and compute the sum of the 3 products. Since a 3 is in the 64's column, you multiply to obtain 192. Since 4 is in the 8's column, you multiply 4 x 8 to get 32. Then add 32 to the 192 from the step before to get a running total of 224. Finally, since a 5 is in the 1's column, multiply 1 x 5 to get the product of 5 and add it to the running toal of 224 to get 229. That final value, 229, is the decimal equivalent to the original number 345 (base 8).

    View an example - binary to decimal : octal to decimal : hex to decimal

  2. Formal way: Expand the number 345 (base 8) into expanded form. Expanded form is written as

    (3 x 82) + ( 4 x 81) + (5 x 80) = 229

    View an example: binary to decimal - octal to decimal -hex to decimal

III. To convert a decimal number into a base other than 10

  1. Write out the powers in the other base starting at the power of 0 until you reach a number higher than the given number.
  2. Divide the highest power of the base that can divided at least once into the given number.
  3. Put the quotient of that division into a column that will eventually be the leftmost digit of the final answer.
  4. Continue steps 2 & 3 using the remainder of the previous division but add each successive quotient to the right of previous quotients in the final answer.

    View an example: decimal to binary - decimal to octal - decimal to hex

Computer Number System Worksheets

CNS Worksheet #1 (addition)
CNS Worksheet #2 (bin/oct/hex to decimal conversion)
CNS Worksheet #3 (decimal to bin/oct/hex conversion)
CNS Worksheet #4 (addition, subtraction, conversion, & bin/hex conversion)