Docsity

Computer Science Homework: Binary Representation and 2's Complement, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
Feb 3, 2010 SOLUTION 1/2
ECSE-2610 Computer Components and Operations
Homework # 1
Due Wednesday, February 3, 2010 in studio
Individual activities. Show your calculations.
1. (3 points) Give the sign-magnitude binary form of:
(a) +1210 (8 bits) = 0000 1100
(b) -1210 (8 bits) = 1000 1100
(c) -12110 (8 bits) = 1111 1001
2. (3 points) Convert to two’s-complement binary form:
(a) +1210 (8 bits) = 0000 1100
(b) -1210 (8 bits) = 1111 0100
(c) -12110 (8 bits) = 1000 0111
3. (4 points) Convert the following decimal numbers to binary form
with 4 bits before and 4 bits after the binary point:
(a) 2.75 = 0010.1100
(b) 13.375 = 1101.0110
4. (6 points) Binary addition and subtraction in 8-bit sign-magnitude form
Check for overflow.
(a) 00110110
+00101001
01001111
(b) 00110110
-00101001
00001101
(c) 00101001
-00110110
10001101
(d) 01111001
+11111001
00000000 (or 10000000)
(e) 01111001
+01111001
11110010 OVERFLOW (sum of two positive integers > 0111 1111)
(f) 11111001
+11111001
11110010 OVERFLOW (sum of two negative integers < 1111 1111)
We shall later study a quick, reliable method for detecting overflow.
pf2

Partial preview of the text

Download Computer Science Homework: Binary Representation and 2's Complement and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Feb 3, 2010 SOLUTION 1/

ECSE-2610 Computer Components and Operations

Homework # 1

Due Wednesday, February 3, 2010 in studio

Individual activities. Show your calculations.

  1. (3 points) Give the sign-magnitude binary form of:

(a) +12 10 (8 bits) = 0000 1100

(b) -12 10 (8 bits) = 1000 1100

(c) -121 10 (8 bits) = 1111 1001

  1. (3 points) Convert to two’s-complement binary form:

(a) +12 10 (8 bits) = 0000 1100

(b) -12 10 (8 bits) = 1111 0100

(c) -121 10 (8 bits) = 1000 0111

  1. (4 points) Convert the following decimal numbers to binary form with 4 bits before and 4 bits after the binary point:

(a) 2.75 = 0010.

(b) 13.375 = 1101.

  1. (6 points) Binary addition and subtraction in 8-bit sign-magnitude form Check for overflow.

(a) 00110110

01001111

(b) 00110110

  • 00001101

(c) 00101001

  • 10001101

(d) 01111001

00000000 (or 10000000)

(e) 01111001

11110010 OVERFLOW (sum of two positive integers > 0 111 1111)

(f) 11111001

11110010 OVERFLOW (sum of two negative integers < 1 111 1111) We shall later study a quick, reliable method for detecting overflow.

Feb 3, 2010 SOLUTION 2/

  1. (4 points) Perform the following additions of 2’s complement numbers, showing all the carries. Verify the addition by converting to decimal.

(a) 0011 1110

(b) 1100 0011

  1. (5 points)

(a) What is the largest 10-bit sign-magnitude number? 01 1111 1111 = 511

(b) What is the smallest (i.e., negative) 10-bit sign-magnitude number? 11 1111 1111= -

(c) What is the largest 10-bit 2’s complement number? 01 1111 1111 = 511

(d) What is the smallest 10-bit 2’s complement number? 10 0000 0000 = -

(e) How many different values can be represented with 12 bits? 4096