CS 231 Spring 2011
Homework 5 Solutions
Addition and Subtraction
1. (10 pts) Change the following numbers to the specified format:
a. 35
10
to
8bit One's Complement Binary
Solution:
+39 to binary is 0010 0111,
then complement bits to get to One's Complement:
1101 1000
b. 123
10
to
8bit Two's Complement Binary
Solution:
+123 to binary is 0111 1011,
then complement bits to get 1000 0100,
now add 1 to get:
1000 0101
c. 63
10
to
8bit Two's Complement Binary
Solution:
+69 in
8bit Two's Complement
format is the same as unsigned binary,
so we convert as usual and get:
0100 0101
d. 1101 0101 from
8bit Two's Complement Binary
into
Decimal
Solution:
To find the magnitude, we must first convert it to a positive number.
Complement bits to get 0010 1010, then add 1 to get 0010 1011.
This has a magnitude of 43, we were looking for a negative number:
43
e. 1000 0110 from
8bit Two's Complement Binary
into
One's Complement Binary
Solution:
First Method
Make the number positive by flipping the bits to get 0111 1001,
and then adding 1 to get 0111 1010.
Now flip the bits back to get One's Complement:
1000 0101
Second Method
Just subtract 1 and get:
1000 0101
2. (15 pts) Assume the following are 8bit numbers in 2's complement format.
Perform the
computations below to produce 8bit results.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
For each part, show the results of your computation, indicate whether the operation overflows, and
convert the operands and results to decimal to check the computation.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 Staff
 Addition, 4bit, negative number

Click to edit the document details