Computer Architecture
Tutorial 3 – Number Representation and Binary Arithmetic –
Answers
1) Convert the following binary numbers to decimal:
(a) 0110 = 6, (b) 1011 = 11, (c) 10101010 = 170
2) Convert the following binary numbers to hexadecimal:
(a) 1110 = E, (b) 11011 = 1B, (c) 1010111101110010 = AF72
3) Convert the following decimal numbers to binary and hexadecimal:
(a) 12 = 1100 & C, (b) 27 = 11011 & 1B, (c) 96 = 1100000 & 60
4) For an 8-bit group, work out the representation for -3710 in
3710 = 100101
a) Sign & Magnitude 10100101
b) One’s Complement 11011010
c) Two’s Complement 11011011
d) Excess-255 -37 = -37 + 255 = 218 = 11011010
e) Excess-128 -37 = -37 + 128 = 91 = 01011011
5) Express 9876510 in Binary Coded Decimal
9 8 7 6 5 1 0
1001 1000 0111 0110 0101 0001 0000
6) Form the negative equivalent of the following 8-bit Two’s Complement numbers.
(a) 00011001, (b) 00011110, (c) 01101000, (d) 01110100
(a) 00011001 = 16 + 8 + 1 = 2510
“invert the bits and add 1” 11100110 + 1 = 11100111
check: 11100111 = -128 + (64 + 32 + 4 + 2 + 1) = -2510
——
(b) 00011110 = 16 + 8 + 4 + 2 = 3010
“invert the bits and add 1” 11100001 + 1 = 11100010
check: 11100010 = -128 + (64 + 32 + 2) = -3010
——
(c) 01101000 = 64 + 32 + 8 = 10410
“invert the bits and add 1” 10010111 + 1 = 10011000
check: 10011000 = -128 + (16 + 8) = -10410
——
(d) 01110100 = 64 + 32 + 16 + 4 = 11610
“invert the bits and add 1” 10001011 + 1 = 10001100
check: 10001100 = -128 + (8 + 4) = -11610
by comparing the resulting bit patterns to the originals, can you spot a “short cut”
method for the conversion?
Take another look at the bit patterns:
positive: 00011001 00011110 01101000 01110100
negative: 11100111 11100010 10011000 10001100
“starting from the rightmost bit (lsb), copy each bit unchanged up to and including the
first 1 then invert all the remaining bits”
7) Perform the following 12-bit two’s complement subtraction
1010 1010 1011 − 1011 0000 1101
Two’s Complement subtraction: “negate the subtrahend and add”
Two’s Complement negation: “invert the bits and add 1”
101100001101 = 010011110010 + 1 = 010011110011
1010 1010 1011
+ 0100 1111 0011
——————–
1111 1001 1110
Check your answer by determining the decimal representation of the numbers and
the result
1010 1010 1011 = −2048 + 683 = −1365
-1011 0000 1101 = −(−2048 + 781 = −1267)
————– —–
1111 1001 1110 = −2048 + 1950 = -98
8) Perform the binary multiplication 10011 x 1101
10011 x
1101
———–
1101 +
1101
————
100111 +
1101
——————
11110111
In decimal: 19 x 13 = 247
9) Divide the binary number 1011111 by 101
10011
—————
101 | 1011111
– 101
————–
001111-
101
———-
101
In Decimal: 95 / 5 = 19