Está en la página 1de 8

Michael S.

Walker
September 15, 2018

COMP 2655: Computing Machinery I


Assignment 1: PART 1

1. Convert each question as specified:


a) 10213 to base10 by summing the expanded notation.

dn ∗ B n + dn−1 ∗ B n−1 + · · · + d2 ∗ B 2 + d1 ∗ B 1 + d0

10213 ⇒ base10
=⇒ 1 ∗ 3 + 0 ∗ 3 + 2 ∗ 31 + 1 ∗ 30
3 2

= 27 + 0 + 6 + 1
= 3410

b) 110 101 1012 to base10 using Horner’s rule.

((((dn ∗ B + dn−1 ) ∗ B + dn−2 ∗ B + · · · + d2 ) ∗ B + d1 ) ∗ B + d0 )

110 101 1012 ⇒ base10


=⇒ ((((((((2 ∗ 1 + 1) ∗ 2 + 0) ∗ 2 + 1) ∗ 2 + 0) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 0) ∗ 2 + 1)
= 42910

c) 461148 to base16 using the fact that these are related bases.

4611488 ⇒ base16
=⇒ 100 110 001 001 1002
=⇒ 0100 1100 0100 11002
= 4C4C16

d) 335510 to base9 using any method.

335510 ⇒ base9
=⇒  372  41  4  0
9 3355 9 372 9 41 9 4
2700 360 36
655 12 5
630 9
25 3
18
7
= 45379

1
e) 10356 to base7 using any method.

((((dn ∗ B + dn−1 ) ∗ B + dn−2 ∗ B + · · · + d2 ) ∗ B + d1 ) ∗ B + d0 )

10356 ⇒ base10
=⇒ (((6 ∗ 1 + 0) ∗ 6 + 3) ∗ 6 + 5)
= 23910
base10 ⇒ base7
 34  4  0
7 239 7 34 7 4
210 28
29 6
28
1
= 4617

2. Purely in binary, add : 1100 0100 11112 1000 1010 11012

(carry) 1 1 1 1 1

0 0 0 0 1 1 0 0 0 1 0 0 1 1 1 12 Addend
+ 0 0 0 0 1 0 0 0 1 0 1 0 1 1 0 12 Augend
0 0 0 1 0 1 0 0 1 1 1 1 1 1 0 02 Sum

3. Purely in binary, subtract: 1100 0100 11112 - 1000 1010 11012

(carry) 10 1 Z
Z 10 1 10 10

0 1 1
A 0 0 0 1A 0 0 1 1 1 12 Minuend
+ 0 1 0 0 0 1 0 1 0 1 1 0 12 Subtrahend
0 0 0 1 1 1 0 1 0 0 0 1 02 Difference

2
4. Purely in hex, add: 4 A 0 C 8 716 + 3 0 F D 2 216

(carry) 1 1

4 A 0 C 8 716 Addend
+ 3 0 F D 2 216 Augend
7 B 0 9 A 916 Sum

temp = Addend-digit(n) + Augend-digit(n),


where (n) is the digit position and the addition is in base_10
sum = temp mod base
carry = temp div base
Base_10 Sum, and Carry Results:
-------------------------------
digit(0): sum = 09 mod 16 = 09
carry = 09 div 16 = 00

digit(1): sum = 10 mod 16 = 10 (A)_16


carry = 10 div 16 = 00

digit(2): sum = 25 mod 16 = 09


carry = 25 div 16 = 01

digit(3): sum = 16 mod 16 = 00


carry = 16 div 16 = 01

digit(4): sum = 11 mod 16 = 11 (B)_16


carry = 11 div 16 = 00

digit(5): sum = 07 mod 16 = 07


carry = 07 mod 16 = 00
-------------------------------

5. Purely in hex, subtract: 4 A 0 C 8 716 - 3 0 F D 2 216

(carry) 9 10F
Z 10

A 0
4 @ C 8 716 Minuend
− 3 0 F D 2 216 Subtrahend
1 9 0 F 6 516 Difference

3
6. The number below, uses 12-bit 20 s complement base2 representation, answer the following:
a) 0101 1110 10012 is this number negative? Why, or why not?

(msb)->[0]101 1110 1001 base_2, 2’s compliment.


----------------------------------------
This number is positive,
since the (msb) most significant
bit is 0. there for, it’s not negative.

b) Apply the 20 s complement negation operation to 0101 1110 10012


is it a negative number ? Explain your answer

Step 1.
−x = (¬x + 1)

=⇒ ¬(0101 1110 10012 ) + 12


= 1010 0001 01102 + 12
= 0001 01112 twos compliment.

Since the most signif icant bit (msb)


determines the sign of our 8 bit number
the value [1]010 0001 01112 twos compliment.
appears to be negative.

Step 2.
−x = (¬x + 1)

V erif y step 1.
¬(1010 0001 01112 ) + 12
= 0101 1110 10002 + 12
= 0101 1110 10012 twos compliment.

U sing horners rule, on the binary value 0101 1110 10012


((((dn ∗ B + dn−1 ) ∗ B + dn−2 ∗ B + · · · + d2 ) ∗ B + d1 ) ∗ B + d0 )
(((((((((((2 ∗ 0 + 1) ∗ 2 + 0) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 0) ∗ 2 + 1) ∗ 2 + 0) ∗ 2 + 0) ∗ 2 + 1)
gives the value,
151310
we know this is negative.
∴ (¬(0101 1110 10012 ) + 1) = −151310

4
7. In 6 bit 2’s complement base2 , what are the largest and the smallest values which can be represented?:
a) give binary bit patterns for both values.
b) decimal numbers corresponding to each binary number from part a).

T he largest value that can be stored is


2n−1 − 1

26−1 − 1
= 32 − 1
= 3110
U sing the division method gives,
 15  7  3  1  0
2 31 2 15 2 7 2 32 1
20 14 6 2
11 1 1 1
10
1

=⇒ 3110 = 011 1112 twos compliment.

T he smallest value that can be stored is


−(2n−1 )

−(26−1 )
= −3210
∵ | − 3210 | = 3210 ∧ 3110 = 011 1112
=⇒ 011 1112 + 1 = 100 0002 twos compliment.

8. In 6-bit 2s complement base2 are there any value(s) whose result when applying the
2’s complement negation operation does not result in a different value?
If yes, then state these value(s), in binary:

−value = ¬value + 1

V alue one
000 0002 twos compliment.
¬(000 000)2 + 1
= 111 1112 + 1
= 000 0002 twos compliment.

V alue two
100 0002 twos compliment.
¬(100 000)2 + 1
= 011 1112 + 1
= 100 0002 twos compliment.

5
9. Assuming a fixed length of 8 bits (1 byte), represent the following decimal numbers in signed magnitude base2 :
a) 3010
b) -13010

V alues used f or base2 conversion.


2 = 128 2 = 64 2 = 32 2 = 16 23 = 8 22 = 4 21 = 2 20 = 1
7 6 5 4

16 + 8 + 4 + 2 = 3010
∴ 3010 = 0001 11102 SM

−(2n−1 − 1)

=⇒ −(28−1 − 1)
= −(128 − 1)
= −12710
∵ (| −13010 |) > (| −12710 |)
0
−13010 can t be represented in 8 bit signed magnitude.

10. Repeat the above, represent in 2’s compliment base2 :

Calculation done in question 9.


3010 = 0001 11102 two0 s compliment

−(2n−1 )

=⇒ −(28−1 )
= −12810
∵ (| −13010 |) > (| −12810 |)
0
−13010 can t be represented in 8 bit twos compliment.

6
11. Assume a computer is using signed magnitude base2 representation to store 8-bit values.
Further, assume you have a program which can display the contents of 1-byte memory locations.
However, the program displays hex (as a shorthand) instead of binary.
What decimal values are represented by the following:
a) 9016
b) 7A16

P art a
9016
since,
016 = 00002 ∧ 916 = 10012
9016 = 1001 00002
however 9016 > ±12710
the sign bit can0 t be used
∴ the value does not f it.

P art b
7A16
716 = 01112 ∧ A16 = 10102
=⇒ 7A16 = 0111 10102 SM
since, the sign bit (sb) is 0 the value is positive.

U sing horners rule, on the binary value 0111 10102


((((dn ∗ B + dn−1 ) ∗ B + dn−2 ∗ B + · · · + d2 ) ∗ B + d1 ) ∗ B + d0 )
(((((((2 ∗ 0 + 1) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 0) ∗ 2 + 1) ∗ 2 + 0)
gives the value,
12210
∴ 0111 10102 SM = 12210

7
12. Repeat the above, but assume the numbers are stored as 8-bit 2’s complement base2 :

P art a
9016
since, 916 = 10012 and 016 = 00002
=⇒ ¬(1001 00002 ) + 1
= 0110 11112 + 1
= 0111 00002 twos compliment

horners rule, on the binary value 0111 00002


((((dn ∗ B + dn−1 ) ∗ B + dn−2 ∗ B + · · · + d2 ) ∗ B + d1 ) ∗ B + d0 )
(((((((2 ∗ 0 + 1) ∗ 2 + 1) ∗ 2 + 1) ∗ 2 + 0) ∗ 2 + 0) ∗ 2 + 0) ∗ 2 + 0)
we get
11210
since the most signif icant bit (msb) is 1 the value is negative.
∴ 1001 00002 twos compliment = −11210

P art b
7A16
716 = 01112 ∧ A16 = 10102
=⇒ 7A16 = 0111 10102
since the most signif icant bit (msb) is 0 the value is positive.
Calculation done in question 11
∴ 0111 10102 two0 s compliment = 12210

También podría gustarte