You are on page 1of 17

Level-3, Term-2 (‘17th Batch)

EEE-365: Digital Electronics


Introduction to number systems & codes
Dr. Sampad Ghosh
Assistant Professor
Department of Electrical and Electronic Engineering
Faculty of Electrical and Computer Engineering
Chittagong University of Engineering and Technology (CUET)

February 15, 2021


CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET)
KYUSHU UNIVERSITY
Topics Reference
Introduction to number systems & codes
Numerical representation, Digital & Analog systems,
Digital number systems, Binary to Decimal
conversions, Decimal to Binary conversions, Hexa-
Tocci
decimal number systems, BCD code, The Gray code,
Alphanumeric codes, Parity method for error
detection
Octal & Hexa-decimal numbers, Complements Mano

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 2


1.5 Complements
❑ Used for
o Simplifying subtraction
o Logical manipulation

❑ Two types
1. r’s complement rn - N N≠0 N = positive integer

0 N=0 r = base (e.g., 2, 10, 8, 16)


n = number of digits (integer part)
2. (r-1)‘s complement rn – r-m -N
m = number of digits (fraction part)

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 3


1.5 Complements …

❑ 10’s complement of (52520)10 rn - N

105 – 52520 = 47480 N = 52520, r = 10, n = 5

❑ 10’s complement of (0.3267)10

100 – 0.3267 = 0.6733 N = 0.3267, r = 10, n = 0

Test: 10’s complement of (25.639)10 102 – 25.639 = 74.361

❑ 2’s complement of (101100)2


N = 101100, r = 2, n = 6

(26)10 – (101100)2 = (1000000-101100)2=010100

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 4


1.5 Complements …
(r-1)‘s complement rn – r-m - N
❑ 9’s complement of (52520)10

105 – 10-0 – 52520 = 47479 N = 52520, r = 10, n = 5, m = 0

❑ 9’s complement of (0.3267)10

100 – 10-4 – 0.3267 = 0.6732 N = 0.3267, r = 10, n = 0, m = 4

❑ 1’s complement of (101100)2


N = 101100, r = 2, n = 6

(26 – 20)10 – (101100)2 = (111111-101100)2=010011

Test: 1’s complement of (0.0110)2 (1 – 2-4)10 – (0.0110)2 = 0.1001

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 5


1.5 Complements …

Test: Find the 10’s complement of (935)11 2 marks

(11-1)‘s complement of (935)11 (r-1)‘s complement rn – r-m - N

(113 – 11-0)10 – (935)11 N = 935, r = 11, n = 3, m = 0

= (1330)10 – (1127)10
= (203)10 (935)11 = (5x110 + 3x111 9x112)10 = (1127)10

= (175)11 203/11 = 18 5
18/11 = 1 7
1/11 = 0 1

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 6


Subtraction with r’s complements
❑ Subtraction of two positive numbers (M – N), both base r
1. Add minuend M to r's complement of subtrahend N.
2. Inspect result obtained in step-1 for an end carry
o If an end carry produce, discard it.
o If an end carry does not produce, take r's complement of sum in step-1 and
place a negative sign in front.

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 7


Subtraction with r’s complements …
❑ Using 10’s complement, subtract 72532 – 3250
1. r's complement of N
M = 72532
2. Then add to M
N = 03250 3. Check
o If end carry, discard it.
1. 10‘s complement of N = 96750
o If no end carry, take r's
complement of sum and
2.
72532 place a negative sign in
front.
+ 96750
169282
3.
End carry
Ans. 69282

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 8


Subtraction with r’s complements …
❑ Using 10’s complement, subtract 3250 – 72532 1. r's complement of N
2. Then add to M
M = 03250
3. Check end carry
N = 72532 o If end carry, discard it.
o If no end carry, take r's
1. 10‘s complement of N = 27468 complement of sum and
place a negative sign in
2. front.
03250
+ 27468
030718 10‘s complement of 30718 = 69282
3.
No carry
Ans. – 69282

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 9


Subtraction with r’s complements …
❑ Using 2’s complement, subtract ❑ Using 2’s complement, subtract
1010100 – 1000100 1000100 – 1010100

M = 1010100 M = 1000100

N = 1000100 N = 1010100

2‘s complement of N = 0111100 2‘s complement of N = 0101100


1000100
1010100 + 0101100
+ 0111100 No carry 01110000
10010000
Ans. – (2‘s complement of 1110000)
End carry
Ans. 10000 – 10000

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 10


Subtraction with (r-1)’s complements
❑ Subtraction of two positive numbers (M – N), both base r
1. Add minuend M to (r-1)'s complement of subtrahend N.
2. Inspect result obtained in step-1 for an end carry
o If an end carry produce, add 1 to LSB (end-around carry).
o If an end carry does not produce, take (r-1)'s complement of sum in step-1
and place a negative sign in front.

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 11


Subtraction with (r-1)’s complements …
❑ Using 9’s complement, subtract 72532 – 3250
1. (r-1)'s complement of N
M = 72532
2. Then add to M
N = 03250 3. Check
o If end carry, add 1 to LSB.
1. 9‘s complement of N = 96749
o If no end carry, take r's
complement of sum and
2.
72532 place a negative sign in
front.
+ 96749
3. 169281
End-carry 69281
+ 1
Ans. 69282
69282
CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 12
Subtraction with (r-1)’s complements …
❑ Using 9’s complement, subtract 3250 – 72532
1. (r-1)'s complement of N
M = 03250
2. Then add to M
N = 72532 3. Check
o If end carry, add 1 to LSB.
1. 9‘s complement of N = 27467
o If no end carry, take (r-1)'s
complement of sum and place
2.
03250 a negative sign in front.

+ 27467
3. 030717
No carry

Ans. – (9‘s complement of 30717) = - 69282

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 13


Subtraction with (r-1)’s complements …
❑ Using 1’s complement, subtract ❑ Using 1’s complement, subtract
1010100 – 1000100 1000100 – 1010100

M = 1010100 M = 1000100

N = 1000100 N = 1010100

1‘s complement of N = 0111011 1‘s complement of N = 0101011

1010100 1000100
+ 0111011 + 0101011

10001111
No carry 01101111

End carry 0001111


Ans. – (1‘s complement of 1101111)
+ 1
0010000 – 10000
Ans. 10000
CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 14
Test

❑ Subtract using 2’s and 1’s complement and check with straight
subtraction 100 – 110000
2 marks

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 15


Self Study

❑ Comparison between 1’s and 2’s complements - Mano


❑ Problems (ch-1) from Mano

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 16


Summary

❑ Complements
❑ Subtract using complements

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY (CUET) 17

You might also like