Thursday, February 5, 2009

Computer Number Systems

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
o base 10
o valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
2. Binary System
o base 2
o valid digits - 0, 1
3. Octal System
o base 8
o valid digits - 0, 1, 2, 3, 4, 5, 6, 7
4. Hexadecimal System
o base 16
o valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
o 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
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).


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

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.

No comments:

Followers