Coa Unit1 Chapter2
Coa Unit1 Chapter2
• Data are numbers and other binary-coded information that are operated on
• All types of data, except binary numbers, are represented in binary-coded form
• A number system of base, or radix, r is a system that uses distinct symbols for r
digits
• Numbers are represented by a string of digit symbols
2 1 0 -1
7 x 10 + 2 x 10 + 4 x 10 + 5 x 10
• The string of digits 101101 in the binary number system represents the quantity
5 4 3 2 1 0
1 x 2 + 0 x 2 + 1 x 2 + 1 x 2 + 0 x 2 + 1 x 2 = 45
• (101101)2 = (45)10
• We will also use the octal (radix 8) and hexidecimal (radix 16) number systems
2 1 0 -1
(736.4)8 = 7 x 8 + 3 x 8 + 6 x 8 + 4 x 8 = (478.5)10
1 0
(F3)16 = F x 16 + 3 x 16 = (243)10
M = 13250
10’s comp. of N = +27468
Sum = 40718
No end carry
Answer = -59282 (10’s comp. of 40718)
Example for X = 1010100 and Y = 1000011
X = 1010100
2’s comp. of Y = +0111101
Sum = 10010001
Discard end carry = -10000000
Answer X – Y = 0010001
Y = 1000011
2’s comp. of X = +0101100
Sum = 1101111
No end carry
Answer = -0010001 (2’s comp. of 1101111)
• When an integer is positive, the msb, or sign bit, is 0 and the remaining bits
represent the magnitude
• When an integer is negative, the msb, or sign bit, is 1, but the rest of the number
can be represented in one of three ways
o Signed-magnitude representation
o Signed-1’s complement representation
o Signed-2’s complement representation
+6 00000110 -6 11111010
+13 00001101 +13 00001101
+19 00010011 +7 00000111
+6 00000110 -6 11111010
-13 11110011 -13 11110011
-7 11111001 -19 11101101
• An overflow occurs when two numbers of n digits each are added and the
sum occupies n + 1 digits
• Overflows are problems since the width of a register is finite
• Therefore, a flag is set if this occurs and can be checked by the user
• Detection of an overflow depends on if the numbers are signed or unsigned
• For unsigned numbers, an overflow is detected from the end carry out of the msb
• For addition of signed numbers, an overflow cannot occur if one is positive and
one is negative – both have to have the same sign
• An overflow can be detected if the carry into the sign bit position and the carry
out of the sign bit position are not equal