Dale - Computer Science Illuminated 66

Dale - Computer Science Illuminated 66 - Because there isnt...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
2.2 Natural Numbers 39 1*2 6 = 1 * 64 = 64 +0*2 5 = 0 * 32 = 0 +1*2 4 = 1 * 16 = 16 +0*2 3 = 0 * 8 = 0 +1*2 2 = 1 * 4 = 4 +1*2 1 = 1 * 2 = 2 +0*2 0 = 0 * 1 = 0 86 Recall that the digits in any number system go up to one less than the base value. To represent the base value in that base, you need two digits. In any base, a 0 in the rightmost position and a 1 in the second position represent the value of the base itself. So 10 is ten in base 10 and 10 is eight in base 8 and 10 is sixteen in base 16. Think about it. The consistency of number systems is actually quite elegant. Addition and subtraction of numbers in other bases are performed exactly like they are on decimal numbers. Arithmetic in Other Bases Recall the basic idea of arithmetic in decimal. 0 + 1 is 1, 1 + 1 is 2, 2 + 1 is 3, and so on. Things get interesting when you try to add two numbers whose sum is equal to or larger than the base value. For example: 1 + 9.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Because there isnt a symbol for 10, we reuse the same digits and rely on position. The rightmost digit reverts to 0, and there is a carry into the next position to the left. Thus 1 + 9 equals 10 in base 10. The rules of binary arithmetic are analogous, but we run out of digits much sooner. 0 + 1 is 1, and 1 + 1 is 0 with a carry. Then the same rule is applied to every column in a larger number, and the process continues until there are no more digits to add. The example below adds the binary values 101110 and 11011. The carry value is marked above each column in color. 11111 carry 101110 + 11011 1001001 We can convince ourselves that this answer is correct by converting both operands to base 10, adding them, and comparing the result. 101110 is 46, 11011 is 27, and the sum is 73. 101001 is 73 in base 10....
View Full Document

This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.

Ask a homework question - tutors are online