**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

- Decimal System
- base 10
- valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

- Binary System
- base 2
- valid digits - 0, 1

- Octal System
- base 8
- valid digits - 0, 1, 2, 3, 4, 5, 6, 7

- Hexadecimal System
- base 16
- valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
- A refers to decimal 10, B refers to decimal 11, etc.

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

- 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

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

(3 x 8^{2}) + ( 4 x 81) + (5 x 8^{0}) = 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

- Write out the powers in the other base starting at the power of 0 until you reach a number higher than the given number.
- Divide the highest power of the base that can divided at least once into the given number.
- Put the quotient of that division into a column that will eventually be the leftmost digit of the final answer.
- 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)