Docsity

Solution to Homework 2 in ECE 2504 Introduction to Computer Engineering, Fall 2008 - Prof., Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
SOLUTION
ECE 2504 Introduction to Computer Engineering, Fall 2008
Homework 2
Due date: 8 Sep 08, 11:59pm
Show all work.
1. (6 pts) Find the decimal equivalent of the following two’s complement numbers:
1010110; 10000101; 01011011; 111100110; 10011011; 11110000
a. 1010110 is the 2’s complement of 0101010
0101010
= 1×25 + 0×24 + 1×23 + 0×22 + 1×21 + 0×20
= 32 + 0 + 8 + 0 + 2 + 0
= 42
1010110 ≡ (- 42)10
b. 10000101 is the 2’s complement of 01111011
01111011
= 1×26 + 1×25 + 1×24 + 1×23 + 0×22 + 1×21 + 1×20
= 64 + 32 + 16 + 8 + 0 + 2 + 1
= 123
10000101 ≡ (- 123)10
c. 01011011 is a positive number
01011011
= 1×26 + 0×25 + 1×24 + 1×23 + 0×22 + 1×21 + 1×20
= 64 + 0 + 16 + 8 + 0 + 2 + 1
≡ 9110
d. 111100110 is the 2’s complement of 000011010
000011010
= 0×27 + 0×26 + 0×25 + 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= 0 + 0 + 0 + 16 + 8 + 0 + 2 + 0
= 26
111100110 ≡ (- 26)10
e. 10011011 is the 2’s complement of 01100101
01100101
= 1×26 + 1×25 + 0×24 + 0×23 + 1×22 + 0×21 + 1×20
= 64 + 32 + 0 + 0 + 4 + 0 + 1
= 101
10011011 ≡ (- 101)10
f. 11110000 is the 2’s complement of 00010000
00010000
= 0×26 + 0×25 + 1×24 + 0×23 + 0×22 + 0×21 + 0×20
= 0 + 0 + 16 + 0 + 0 + 0 + 0
= 16
11110000 ≡ (- 16)10
pf3
pf4
pf5

Partial preview of the text

Download Solution to Homework 2 in ECE 2504 Introduction to Computer Engineering, Fall 2008 - Prof. and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Due date: 8 Sep 08, 11:59pm

Show all work. c. 01011011 is a positive number

 - ECE 2504 Introduction to Computer Engineering, Fall - Homework 
  • 1010110; 10000101; 01011011; 111100110; 10011011; 1. (6 pts) Find the decimal equivalent of the following two’s complement numbers:
  • a. 1010110 is the 2’s complement of
    • = 1×2^5 + 0×2^4 + 1×2^3 + 0×2^2 + 1×2^1 + 0×2
    • = 32 + 0 + 8 + 0 + 2 +
    • =
  • 1010110 ≡ (- 42)
  • b. 10000101 is the 2’s complement of - = 1×2^6 + 1×2^5 + 1×2^4 + 1×2^3 + 0×2^2 + 1×2^1 + 1×2 - = 64 + 32 + 16 + 8 + 0 + 2 + - =
  • 10000101 ≡ (- 123)
    • = 1×2^6 + 0×2^5 + 1×2^4 + 1×2^3 + 0×2^2 + 1×2^1 + 1×2
      • = 64 + 0 + 16 + 8 + 0 + 2 +
    • ≡
  • d. 111100110 is the 2’s complement of
    • = 0×2^7 + 0×2^6 + 0×2^5 + 1×2^4 + 1×2^3 + 0×2^2 + 1×2^1 + 0×2
    • = 0 + 0 + 0 + 16 + 8 + 0 + 2 +
    • =
  • 111100110 ≡ (- 26)
  • e. 10011011 is the 2’s complement of
    • = 1×2^6 + 1×2^5 + 0×2^4 + 0×2^3 + 1×2^2 + 0×2^1 + 1×2
      • = 64 + 32 + 0 + 0 + 4 + 0 +
      • =
  • 10011011 ≡ (- 101)
  • f. 11110000 is the 2’s complement of
    • = 0×2^6 + 0×2^5 + 1×2^4 + 0×2^3 + 0×2^2 + 0×2^1 + 0×2
      • = 0 + 0 + 16 + 0 + 0 + 0 +
      • =
  • 11110000 ≡ (- 16)
  1. (6 pts) Perform the subtraction of the following unsigned decimal numbers by taking the 10’s complement of the subtrahend: 7240 – 3541; 1683 – 6370; 25 – 75.

a. 7240 7240

  • 3541 → + 6459 1 3699 → discard the carry out: +

b. 1683 1683

  • 6370 → + 3630 5313 → there is no carry out, ∴ it is a negative number. Take the 10’s complement to find the magnitude: - 4687

c. 25 25

  • 75 → + 25 50 → there is no carry out, ∴ it is a negative number. Take the 10’s complement to find the magnitude: - 50
  1. (8 pts) Perform the subtraction of the following unsigned binary numbers by taking the 2’s complement of the subtrahend: 11001 – 10101; 11011 – 1011; 1000 – 101100; 1110100 - 1110100.

a. 11001 11001

  • 10101 → + 01011 1 00100 → discard the carry out: +

b. 11011 11011

  • 01011 → + 10101 1 10000 → discard the carry out: +

c. 001000 001000

  • 101100 → + 010100 011100 → there is no carry out, ∴ it is a negative number. Take the 2’s complement to find the magnitude: - 100100

d. 1110100 1110100

  • 1110100 → + 0001100 1 0000000 → discard the carryout: 0000000
  1. (8 pts) Perform the addition of the following 8-bit two’s complement numbers and show the decimal result: 10011011 + 00010010; 00110100 + 00110001; 01011010 + 11010010; 11011010 + 11111110

a. 10011011

  • 00010010 10101101 → - X = 01010011 ≡ 1×2^6 + 0×2^5 + 1×2^4 + 0×2^3 + 0×2^2 + 1×2^1 + 1×2^0 = 64 + 0 + 16 + 2 + 1 = 83 (^10) 10101101 ≡ - 83 10

b. 00110100

  • 00110001 01100101 ≡ 1×2^6 + 1×2^5 + 0×2^4 + 0×2^3 + 1×2^2 + 0×2^1 + 1×2^0 = 101 10
  1. (2 pts) Decode the following ASCII code:

1010110 1101001 1110010 1100111 1101001 1101110 1101001 1100001 0100000 1010100 1100101 1100011 1101000 0100000 1001000 1001111 1001011 1001001 1000101 1010011 0100000 0100001

Virginia Tech HOKIES!

  1. (5 pts) Convert (286.63724) 10 to 32-bit floating point representation in standard IEEE format. Represent your answer in hex.

23 bit mantissa, 8 bit exponent

.63724 × 2 = 1. 27448

.27448 × 2 = 0. 54896

.54896 × 2 = 1. 09792

.09792 × 2 = 0. 19584

.19584 × 2 = 0. 39168

.39168 × 2 = 0. 78336

.78336 × 2 = 1. 56672

.56672 × 2 = 1. 13344

.13344 × 2 = 0. 26688

.26688 × 2 = 0. 53376

.53376 × 2 = 1. 06752

.06752 × 2 = 0. 13504

.13504 × 2 = 0. 27008

.27008 × 2 = 0. 54016

.54016 × 2 = 1. 08032

.08032 × 2 = 0. 16064

100011110.1010001100100010 = 1.000111101010001100100010 × 2 8

= (-1) 0 × 1. 000111101010001100100010 × 2 8

S = 0

e = 8; E = 8 + 127 = 135 F = 00011110101000110010001

438F5191H

  1. (5 pts) Convert BEF4E000H, which is a 32-bit floating point number in IEEE 754 format, to decimal. BEF4E000H 1011 1110 1111 0100 1110 0000 0000 0000 1 01111101 11101001110000000000000

S = 1

E = 125; e = 125 – 127 = - 2 F = 11101001110000000000000

(-1) 1 × 1.11101001110000000000000× 2 - = -. ≡ 1×2-2^ + 1×2 -3^ + 1×2-4^ + 1×2-5^ + 1×2-7^ + 1×2-10^ + 1×2-11^ + 1×2 -

  1. (4 pts) Represent the decimal number 6542 in BCD; excess-3 code; 2421 code; and in hex- coded binary.

a) BCD: 0110 0101 0100 0010 b) XS-3: 1001 1000 0111 0101 c) 2421: 1100 1011 0100 0010 d) Binary: 1 1001 1000 1110 Hex-coded binary: 198E