You are on page 1of 92

LOGIC AND

SEQUENTIAL CIRCUIT
DESIGN

1
DIGITAL SYSTEMS AND BINARY NUMBERS

2
CONTENTS

 Digitization of Analog Signals

 Binary Numbers and Number Systems

 Number System Conversions

 Representing Fractions

3
ANALOG VS DIGITAL SYSTEMS

Analog

Digital

4
DIGITIZATION

 Process of conversion from analog to digital is called digitization

5
COMPUTERS
 Computers are digital systems

 Deal with a vocabulary of two elements namely 0 and 1. This is also

known as the binary system of numbers


 Binary digits i.e. 0 and 1 are called bits

1 1

6
BIT
binary digit 7
NEXT…

 Digitization of Analog Signals

 Binary Numbers and Number Systems

 Number System Conversions

 Representing Fractions

8
BINARY NUMBER SYSTEM
1 6 23
16 6 3
63 21
935 2 3
935 72
Decimal-to-Binary
534 7275 935 935 1 534 Conversion
2 34 37 1
2
1 3 75 3 4
145 7 1452

01 1 00100
1001 11
0 01 0 1 001
0
01 0
110
01
0 10
0 10 1 01
1
1101 1 001
0
0 1 11
001
011
00100
011
0 1 01 0 0
1100
101
01 101 0
1 11011
011 1101
001 00100
Binary-to-Decimal 011 011
01
1
Conversion 010 1 0 1
01 0 101011
11 0010
0 1 01101 1 01011
1
0 0 1 0
1
1
10 0110 001 1 0
1 00
00
9
DECIMAL (BASE 10) NUMBER SYSTEM
CONSISTS OF 10 SYMBOLS OR DIGITS

0 1 2 3 4
5 6 7 8 9
10
WE COUNT IN BASE 10 (DECIMAL)
Ran out of symbols (0-9), so increment the digit on the left by one unit.
0
9 1
0, 1, 2, …, 9,10,…, 8
2
20, …30,…100, … 7
3
6 4
5

18
BINARY (BASE 2) NUMBER SYSTEM
CONSISTS OF JUST TWO

01
12
COMPUTERS COUNT IN BASE 2 (BINARY)
 Counting in Binary is the same, but with only two symbols

10000
1111
1110
1101
1100
1011
1010
1001
1000
111
101
100
110
11
10
1
0
 On (1)
 Off (0)

20
BINARY NUMBERS (BITS)
 Bits can be represented as:
 1 or 0
 On or Off
 Up or Down
 Open or Closed
 Yes or No
 Black or White
 Thick or Thin
 Long or Short

21
DECIMAL (BASE 10) NUMBERS ARE EXPRESSED
IN THE POSITIONAL NOTATION

The right-most is the least significant digit

LSD
THT0
4202 = 2x100 + 0x101 + 2x102 + 4x103

MSD
The left-most is the most significant digit

15
DECIMAL (BASE 10) NUMBERS ARE EXPRESSED
IN THE POSITIONAL NOTATION

1
4202 = 2x100 + 0x101 + 2x102 + 4x103

1’s multiplier

16
DECIMAL (BASE 10) NUMBERS ARE EXPRESSED IN
THE POSITIONAL NOTATION

10
4202 = 2x100 + 0x101 + 2x102 + 4x103

10’s multiplier

17
DECIMAL (BASE 10) NUMBERS ARE EXPRESSED IN
THE POSITIONAL NOTATION

100
4202 = 2x100 + 0x101 + 2x102 + 4x103

100’s multiplier

18
DECIMAL (BASE 10) NUMBERS ARE EXPRESSED IN
THE POSITIONAL NOTATION

1000
4202 = 2x100 + 0x101 + 2x102 + 4x103

1000’s multiplier

19
DECIMAL NUMBERS

 7,392= 7x103 + 3x102 + 9x101 + 2x100


 Generally a decimal number is represented by a series of coefficients

 aj cofficient are any of the 10 digit (0,1,2…9)


 Decimal number are base 10

20
BINARY (BASE 2) NUMBERS ARE ALSO
EXPRESSED IN THE POSITIONAL NOTATION

The right-most is the least significant digit

LSD

10011
16 8 4 2 1 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24
10011 = 1x1 + 1x2 + 0x4 + 0x8 +
1x16

MSD
The left-most is the most significant digit

21
BINARY (BASE 2) NUMBERS ARE ALSO
EXPRESSED IN THE POSITIONAL NOTATION

1
10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

1’s multiplier

22
BINARY (BASE 2) NUMBERS ARE ALSO
EXPRESSED IN THE POSITIONAL NOTATION

2
10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

2’s multiplier

23
BINARY (BASE 2) NUMBERS ARE ALSO
EXPRESSED IN THE POSITIONAL NOTATION

4
10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

4’s multiplier

24
BINARY (BASE 2) NUMBERS ARE ALSO
EXPRESSED IN THE POSITIONAL NOTATION

8
10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

8’s multiplier

25
BINARY (BASE 2) NUMBERS ARE ALSO
EXPRESSED IN THE POSITIONAL NOTATION

16
10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

16’s multiplier

26
Counting
COUNTING IN
Counting
in Decimal
DECIMAL in Binary
0 10 20 30 0 1010 10100 11110
1 11 21 31 1 1011 10101 11111
2 12 22 32 10 1100 10110 100000
3
13 23 33 11 1101 10111 100001
4
14 24 34 100 1110 11000 100010
5
15 25 35 101 1111 11001 100011
6
16 26 36 110 10000 11010 100100
7
8
17 27 . 111 10001 11011 .
9 18 28 . 1000 10010 11100 .
19 29 . 1001 10011 11101 . 27
NEXT…

 Digitization of Analog Signals

 Binary Numbers and Number Systems

 Number System Conversions

 Representing Fractions

28
Binary Decimal
conversion

29
BINARY NUMBERS

 Each binary digit (called a bit) is either 1 or 0

 Bits have no inherent meaning, they can represent …


Most Least
 Unsigned and signed integers
Significant Bit Significant Bit
 Fractions

 Characters 7 6 5 4 3 2 1 0
1 0 0 1 1 1 0 1
 Images, sound, etc.
27 26 25 24 23 22 21 20

 Bit Numbering

 Least significant bit (LSB) is rightmost (bit 0)

 Most significant bit (MSB) is leftmost (bit 7 in an 8-bit number)

30
BINARY NUMBERS

 Coefficient have two possible values 0 and 1


 Strings of binary digits (“bits”)
 n bits can store numbers from 0 to 2 n -1
 n bits can store 2n distinct combinations of 1’s and 0’s
421
 Each coefficient a is multiplied by 2j
j 0- 000
 So 101 binary is 1- 001
2- 010
1 x 22 + 0 x 2 1 + 1 x 2 0 3- 011
or 4- 100
5- 101
1x4 + 0x2 + 1x1=5 6- 110
7- 111 31
CONVERTING BINARY TO DECIMAL

 Each bit represents a power of 2


 Every binary number is a sum of powers of 2

 Decimal Value = (dn-1  2n-1) + ... + (d1  21) + (d0  20)

 Binary (10011101)2 = 27 + 24 + 23 + 22 + 1 = 157

7 6 5 4 3 2 1 0
1 0 0 1 1 1 0 1
27 26 25 24 23 22 21 20

32
CONVERTING BINARY TO DECIMAL

1 0 1 0 1 1 0 0
128 64 32 16 8 4 2 1

128 + 0 + 32 + 0 + 8 + 4 + 0 + 0
128 + 32 + 8 + 4 = 172
33
CONVERTING BINARY TO DECIMAL

0 1 0 1 0 0 0 1
128 64 32 16 8 4 2 1

0 + 64 + 0 + 16 + 0 + 0 + 0 + 1

64 + 16 + 1 = 81
34
CONVERTING BINARY TO DECIMAL

- - -  -   
128 64 32 16 8 4 2 1

0 + 0 + 0 + 16 + 0 + 4 + 2 + 1

16 + 4 + 2 + 1 = 23
35
CONVERTING BINARY TO DECIMAL

       
128 64 32 16 8 4 2 1

128 + 0 + 32 + 16 + 0 + 4 + 2 + 1

128 + 32 + 16 + 4 + 2 + 1 = 183
36
BINARY → DEC : MORE EXAMPLES

a) 0110 2 = ?

b) 11010 2 = ?

c) 0110101 2 = ?

d) 11010011 2 = ?
37
37
BINARY → DEC : MORE EXAMPLES

a) 0110 2 = ? 6 10

b) 11010 2 = ? 26 10

c) 0110101 2 = ? 53 10

d) 11010011 2 = ? 211 10

38
Decimal Binary
conversion

39
CONVERT 75 TO BINARY
2 75 remainder
2 37 1
2 18 1
2 9 0
2 4 1
2 2 0
1 0

1001011 40
CHECK

1001011
1001011 == 1x2 1x2 + 1x2 + 0x2 + 1x2 ++
00
+ 1x2 11
+ 0x2 22
+ 1x2 33

0x2 44
+ 0x2 55
+
0x2 + 0x2 + 1x2 1x2 66

== 11 ++ 22 ++ 00 ++ 88 ++ 00 ++ 00 ++ 64
64

== 75
75

41
CONVERT 100 TO BINARY
2 100 remainder
2 50 0
2 25 0
2 12 1
2 6 0
2 3 0
1 1

1100100 42
DEC → BINARY : MORE EXAMPLES

a) 1310 = ?

b) 2210 = ?

c) 4310 = ?

d) 15810 = ?
43
43
DEC → BINARY : MORE EXAMPLES

a) 1310 = ? 11012

b) 2210 = ? 101102

c) 4310 = ? 1010112

d) 15810 = ? 100111102

44
44
SUMMARY

Base10 Successive
Division
Base2
DECIMAL BINARY
a) Divide the Decimal Number by 2; the remainder is the LSB of Binary
Number .
b) If the Quotient Zero, the conversion is complete; else repeat step (a) using
the Quotient as the Decimal Number. The new remainder is the next most
significant bit of the Binary Number.

Base2 Weighted
Multiplication
Base10
BINARY DECIMAL
a) Multiply each bit of the Binary Number by it corresponding bit-weighting
factor (i.e. Bit-0→20=1; Bit-1→21=2; Bit-2→22=4; etc).
b) Sum up all the products in step (a) to get the Decimal Number.
45
45
BYTES

 Eight bits form a single byte

 “00110011” is One Byte of Information

 Byte Values:

 00000000 = 0
 11111111 = 255

 As a result, binary numbers are mostly written as a full byte


(00000001)

46
SPECIAL POWERS OF 2

 210 (1024) is Kilo, denoted "K"

 220 (1,048,576) is Mega, denoted "M"

 230 (1,073, 741,824)is Giga, denoted "G"

 240 (1,099,511,627,776 ) is Tera, denoted “T"

47
POPULAR NUMBER SYSTEMS

 Binary Number System: Radix (Base) = 2


 Only two digit values: 0 and 1
 Numbers are represented as 0s and 1s

 Octal Number System: Radix (Base) = 8


 Eight digit values: 0, 1, 2, …, 7

 Decimal Number System: Radix (Base) = 10


 Ten digit values: 0, 1, 2, …, 9

 Hexadecimal Number Systems: Radix (Base) = 16


 Sixteen digit values: 0, 1, 2, …, 9, A, B, …, F
 A = 10, B = 11, …, F = 15

 Octal and Hexadecimal numbers can be converted easily to Binary and vice versa

48
OCTAL AND HEXADECIMAL NUMBERS
 Octal = Radix 8 Decimal Binary Octal Hex
Radix 10 Radix 2 Radix 8 Radix 16
 Only eight digits: 0 to 7 0 0000 0 0
1 0001 1 1
 Digits 8 and 9 not used
2 0010 2 2
 Hexadecimal = Radix 16 3 0011 3 3
4 0100 4 4
 16 digits: 0 to 9, A to F 5 0101 5 5
6 0110 6 6
 A=10, B=11, …, F=15
7 0111 7 7
 First 16 decimal values (0 to15) and 8 1000 10 8
9 1001 11 9
their values in binary, octal and hex.
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
49
15 1111 17 F
CONVERTING OCTAL & HEX TO DECIMAL
 Octal to Decimal: N8 = (dn-1  8n-1) +... + (d1  8) + d0

 Hex to Decimal: N16 = (dn-1  16n-1) +... + (d1  16) + d0

 Examples:

(7204)8 = (7  83) + (2  82) + (0  8) + 4 = 3716

(3BA4)16 = (3  163) + (11  162) + (10  16) + 4 = 15268

50
CONVERTING DECIMAL TO OCTAL & HEX

 Repeatedly divide the decimal integer by 16/8

 Each remainder is a hex/octal digit in the translated value

 Example: convert 422 to hexadecimal

16 422 remainder
16 26 6
1 A
(1A6)16
51
CONVERSION BETWEEN BASES

 In general, conversion between bases can be done via decimal:

Base-2
Base-2
Base-3
Base-3
Base-4 Decimal
Base-4

 Shortcuts for conversion between bases 2, 4, 8, 16
….
Base-R
Base-R 52
Bin Hex
0000 0
0001 1

BINARY, OCTAL, AND HEXADECIMAL 0010 2


0011 3
0100 4
 Binary, Octal, and Hexadecimal are related:
0101 5
 Radix 16 = 24 and Radix 8 = 23 0110 6

 0111 7
Hexadecimal digit = 4 bits and Octal digit = 3 bits
1000 8
 Starting from least-significant bit, group each 4 bits 1001 9
 into a hex digit or each 3 bits into an octal digit 1010 A
1011 B
 Example: Convert 32-bit number into octal and hex
1100 C
1101 D
1110 E
3 5 3 0 5 5 2 3 6 2 4 Octal 1111 F

11101011000101101010011110010100 32-bit binary


E B 1 6 A 7 9 4 Hexadecimal
53
BINARY TO OCTAL

 Partition Binary number into group of three digits


each
 The corresponding octal digit is then assigned to each
group
(10110001101011)
(10110001101011)22
== (10
(10110
110001
001101
101011)
011)22
== (26153)
(26153)8
8

54
OCTAL TO BINARY

 Each Octal digit is converted to its three digit binary


equivalent

(26153)
(26153)88 == (010
(010 110
110 001
001 101
101 011)
011)22

55
Bin Hex
0000 0

HEX TO BINARY 0001


0010
1
2
 Convention – write 0x before
0011 3
number 0100 4
 Hex to Binary – just convert 0101 5
digits 0110 6

0x2AC 0111
1000
7
8
1001 9
1010 A
1011 B
0010 1010 1100 1100 C
1101 D
0x2ac = 001010101100 1110 E
1111 F

56
Bin Hex
0000 0
BINARY TO HEX 0001 1
 Just convert groups of 4 bits 0010 2
0011 3

0101001101111011 0100
0101
4
5
0110 6
0101  0011  0111  1011 0111 7
1000 8
1001 9
1010 A
5 3 7 B 1011 B
1100 C
1101 D

101001101111011 = 0x537B 1110


1111
E
F

57
IMPORTANT PROPERTIES
 How many possible digits can we have in Radix r ?

r digits: 0 to r – 1
 What is the result of adding 1 to the largest digit in Radix r?

Since digit r is not represented, result is (10)r in Radix r


Examples: 12 + 1 = (10)2 78 + 1 = (10)8
910 + 1 = (10)10 F16 + 1 = (10)16
 What is the largest value using 3 digits in Radix r?

In binary: (111)2 = 23 – 1 In Radix r:


In octal: (777)8 = 83 – 1 largest value = r3 – 1

In decimal: (999)10 = 103 – 1

58
IMPORTANT PROPERTIES – CONT’D

 How many possible values can be represented …

2n values: 0 to 2n – 1
Using n binary digits?
8n values: 0 to 8n – 1
Using n octal digits
Using n decimal digits? 10n values: 0 to 10n – 1

Using n hexadecimal digits 16n values: 0 to 16n – 1


Using n digits in Radix r ? rn values: 0 to rn – 1

59
NEXT…

 Digitization of Analog Signals

 Binary Numbers and Number Systems

 Number System Conversions

 Representing Fractions

60
REPRESENTING FRACTIONS

 A number Nr in radix r can also have a fraction part:

Nr = dn-1dn-2 … d1d0 .d-1 d-2 … d-m+1 d-m 0 ≤ di < r

Integer Part Fraction Part


Radix Point

 The number Nr represents the value:

Nr = dn-1 × rn-1 + … + d1 × r + d0 + (Integer Part)


d-1 × r -1 + d-2 × r -2 … + d-m × r –m (Fraction Part)

61
EXAMPLES OF NUMBERS WITH
FRACTIONS
 (2409.87) = 2×103 + 4×102 + 9 + 8×10-1 + 7×10-2
10

 (1101.1001) = 23 + 22 + 20 + 2-1 + 2-4 = 13.5625


2

= 7×82 + 3 + 6×8-1 + 4×8-2 = 451.8125


 (703.64)
8

= 10×162 + 16 + 15 + 8×16-1 = 2591.5


 (A1F.8)
16
= 4×52 + 2×5 + 3 + 5-1 = 113.2
 (423.1)
5 Digit 6 is NOT allowed in radix 6

 (263.5)
6

62
CONVERTING DECIMAL FRACTION TO
BINARY
 Convert N = 0.6875 to Radix 2
 Solution: Multiply N by 2 repeatedly & collect integer bits

Multiplication New Fraction Bit


0.6875 × 2 = 1.375 0.375 1 First fraction bit
0.375 × 2 = 0.75 0.75 0
0.75 × 2 = 1.5 0.5 1
0.5 × 2 = 1.0 0.0 1 Last fraction bit

 Stop when new fraction = 0.0, or when enough fraction bits are obtained
 Therefore, N = 0.6875 = (0.1011)2

 Check (0.1011)2 = 2-1 + 2-3 + 2-4 = 0.6875


63
MORE CONVERSION EXAMPLES
 Convert N = 139.6875 to Octal (Radix 8)
 Solution: N = 139 + 0.6875 (split integer from fraction)
 The integer and fraction parts are converted separately

Division Quotient Remainder Multiplication New Fraction Digit


139 / 8 17 3 0.6875 × 8 = 5.5 0.5 5
17 / 8 2 1 0.5 × 8 = 4.0 0.0 4
2/8 0 2

 Therefore, 139 = (213)8 and 0.6875 = (0.54)8


 Now, join the integer and fraction parts with radix point

N = 139.6875 = (213.54)8

64
CONVERSION PROCEDURE TO RADIX R
 To convert decimal number N (with fraction) to radix r

 Convert the Integer Part

 Repeatedly divide the integer part of number N by the radix r and save the
remainders. The integer digits in radix r are the remainders in reverse order of
their computation. If radix r > 10, then convert all remainders > 10 to digits A, B, …
etc.

 Convert the Fractional Part

 Repeatedly multiply the fraction of N by the radix r and save the integer digits that
result. The fraction digits in radix r are the integer digits in order of their
computation. If the radix r > 10, then convert all digits > 10 to A, B, … etc.

 Join the result together with the radix point

65
SIMPLIFIED CONVERSIONS
 Converting fractions between Binary, Octal, and Hexadecimal can be simplified
 Starting at the radix pointing, the integer part is converted from right to left and the
fractional part is converted from left to right
 Group 4 bits into a hex digit or 3 bits into an octal digit

 Use binary to convert between octal and hexadecimal

integer: right to left fraction: left to right

7 2 6 1 3 . 2 4 7 4 5 2 Octal
1 1 1 0 1 0 1 1 0 0 0 1 0 1 1 . 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 1 Binary
7 5 8 B . 5 3 C A 8 Hexadecimal

66
WINDOWS CALCULATOR FOR BINARY
1. Type your number.

3. See new value.

2. Choose notation.

67
WINDOWS CALCULATOR FOR HEX
1. Type your number.

3. See new value.

2. Choose notation.

68
ARITHMETIC -- ADDITION

 Binary similar to decimal arithmetic

No carries
No carries 1 0 1 1 0 0 Carries

0 1 1 0 0 1 0 1 1 0
+ 1 0 0 0 1 + 1 0 1 1 1

1 1 1 0 1 1 0 1 1 0 1

1+1 is 2 (or 102), which results in a carry


69
ARITHMETIC -- SUBTRACTION

2
No borrows 0 0 2 Borrows

1 0 1 1 0 1 1 1 1 0
- 1 0 0 1 0 - 1 0 0 1 1

0 0 1 0 0 0 1 0 1 1

0 - 1 results in a borrow
Borrow makes it (10)2 =(2) 10
70
ARITHMETIC -- MULTIPLICATION

1 0 1 1
X 1 0 1

1 0 1 1
0 0 0 0
1 0 1 1
1 1 0 1 1 1
71
SIGNED BINARY NUMBERS

 It is usual to represent the sign with a bit placed in the leftmost position of the
binary number

Sign bit

Sign
Signbit
bit 00 positive
positive
The Most common notations are: Sign
Signbit
bit 11 negative
negative
 Signed-magnitude system.
 Signed-complement system.

72
SIGNED-MAGNITUDE SYSTEM

• The way we perceive in common arithmetic.


• + for positive and – for negative numbers

• In Computers, to represent a +ve and –ve numbers in


Signed-Magnitude Form
• 1 at left most position for negative number
• 0 at left most position for positive number

73
SIGNED MAGNITUDE SYSTEM
Example
Example11

01001  +9
11001  –9

Example
Example22

3-bit binary pattern


Bit Pattern 000 001 010 011 100 101 110 111

Signed-Magnitude +0 +1 +2 +3 -0 -1 -2 -3
Decimal Value

74
SIGNED-MAGNITUDE SYSTEM
Signed and Unsigned numbers have different interpretations
Examples
Examples

Signed Binary Decimal Equivalent


01001 +9
11001 -9
Un-Signed Binary Decimal Equivalent
01001 9
11001 25

75
SIGNED COMPLEMENT SYSTEM

 In this system, a negative number is indicated by its complement.

 The signed-complement system can use either the 1’s complement or the 2’s

complement notations

76
COMPLEMENTS

 Conventional addition (using carry) is easily implemented in digital computers.

 However; subtraction by borrowing is difficult and inefficient for digital

computers

 Much more efficient to implement subtraction using ADDITION of the

COMPLEMENTS of numbers

77
COMPLEMENTS

 Subtraction by addition

 R’s Complement

 In Binary 2’s complement

 In Decimal 10’s complement

 (R-1) Complement

 In Binary 1’s complement

 In Decimal 9’s Complement

78
DIMINISHED RADIX (R-1)
COMPLEMENT

 Given a number N in base r having n digits, its r-1 complement is

(rn -1 )-N
 Decimal: (10n -1 ) - N

 If n=6 then 106-1=1000000-1=999999

 9’s complement of 546700 is 999999-546700=453299

 In simple words subtract each digit from 9

79
Diminished Radix (r-1) Complement

9’s Complement 9 9 9 9 9 9
Find
Findthe
the9’s
9’scomplement
complementof
of546700
546700and
and12389
12389
- 5 4 6 7 0 0

4 5 3 2 9 9
The
The9’s
9’scomplement
complementof
of546700
546700isis
999999
999999--546700=
546700=453299
453299
9 9 9 9 9
And
Andthe
the9’s
9’scomplement
complementof
of12389
12389isis
99999- 12389==87610.
99999-12389 87610. - 1 2 3 8 9

8 7 6 1 0

80
DIMINISHED RADIX (R-1)
COMPLEMENT
1’s Complement
 Binary: (2n -1 )-N

 If n=4 then 24= (16)10= (10000)2

 24 – 1 = (15)10= (1111)2

 Note: 1-0=1 and 1-1 =0 (Bit Changes)

 In simple words just change the bits

82
Diminished Radix (r-1) Complement

1’s Complement 1 1 1 1 1 1 1

The
Thecomplement
complement1’s1’sofof
- 1 0 1 1 0 0 1

1011001
1011001isis0100110
0100110 0 1 0 0 1 1 0

1 1 1 1 1 1 1

The
The1’s
1’scomplement
complementofof
- 0 0 0 1 1 1 1

0001111
0001111isis1110000
1110000 1 1 1 0 0 0 0

83
RADIX (R) COMPLEMENT

 Given a number N in base r having n digits, its r complement is

(rn –N)

 Simply add one to the radix-1 complement


(rn –N) = [(rn -1 )-N] +1

85
RADIX (R) COMPLEMENT

10’s Complement 1 0 0 0 0 0 0

Find the 10’s complement of 546700


- 5 4 6 7 0 0

and 12389
4 5 3 3 0 0
The 10’s complement of 546700 is
1000000 - 546700= 453300
and the 10’s complement of 12389 is 1 0 0 0 0 0

100000 - 12389 = 87611.


- 1 2 3 8 9

8 7 6 1 1
Notice
Noticethat
thatititisisthe
thesame
sameas
as9’s
9’s
complement
complement++1.1. 86
RADIX (R) COMPLEMENT

2’s Complement 1 0 0 0 0 0 0 0

The
The2’s
2’scomplement
1011001
complementofof
1011001isis0100111
0100111
- 1 0 1 1 0 0 1

0 1 0 0 1 1 1

1 0 0 0 0 0 0 0
The
The2’s
2’scomplement
0001111
complementofof
0001111isis1110001
1110001
- 0 0 0 1 1 1 1

1 1 1 0 0 0 1

87
FAST COMPUTATION OF 2’S
COMPLEMENT
Method
Method1: 1:
The
The2’s
2’scomplement
complementofofbinary
binarynumber
numberisisobtained
obtainedby
byadding
adding11to
tothe
thel’s
l’s
complement
complementvalue.
value.

Example:
1’s complement of 101100 is 010011 (invert the 0’s and 1’s)
2’s complement of 101100 is 010011 + 1 = 010100

88
FAST COMPUTATION OF 2’S
COMPLEMENT
Method
Method22
The
The2’s 2’scomplement
complementcan canbe
beformed
formedbybyleaving
leavingall allleast
leastsignificant
significant0’s 0’sand
andthethe
first
first 11 unchanged,
unchanged, and and then
then replacing
replacing l’s
l’s by
by 0’s
0’s and
and 0’s
0’s by
by l’s
l’s inin all
all other
other
higher
highersignificant
significantbits.
bits.

Example:
The 2’s complement of 1101100 is
0010100
Leave the two low-order 0’s and the first 1 unchanged, and then replacing 1’s
by 0’s and 0’s by 1’s in the four most significant bits.

89
EXAMPLE

 Assuming the representation of the number 9 in binary with 8-bits,


we have the following cases:

 Unsigned 9 or +9 has a the same representation in both signed-

magnitude and signed-complement systems which is: 00001001

 -9 has the signed-magnitude representation: 10001001

 -9 has the signed-1’s complement representation: 11110110

 -9 has the signed-2’s complement representation: 11110111


90
SIGNED COMPLEMENT SYSTEM

4-bit system

Positive values
Negative values
Value Sign-and- 1s 2s Value Sign-and- 1s 2s
Magnitude Comp. Comp. Magnitude Comp. Comp.
+7 0111 0111 0111 -0 1000 1111 -
+6 0110 0110 0110 -1 1001 1110 1111
-2 1010 1101 1110
+5 0101 0101 0101
-3 1011 1100 1101
+4 0100 0100 0100
-4 1100 1011 1100
+3 0011 0011 0011 -5 1101 1010 1011
+2 0010 0010 0010 -6 1110 1001 1010
+1 0001 0001 0001 -7 1111 1000 1001
+0 0000 0000 0000 -8 - - 1000
91
SUBTRACTION WITH R-COMPLEMENT

Subtract N from M : M–N

r’s
r’scomplement
complementofofNN==rrn––NN
n

Add
AddMMtoto((rrn––NN);); Result
n
Result==M
M++((rrn––N)
n
N)

(1) if M  N, simply ignore the carry


(2) if M < N, take the r’s complement of sum and place negative sign in front
of sum. The answer is negative.

92
Example
Example11

Perform the subtraction 72532 - 13250 = 59282.

M > N : Case 1 Discard carry

The 10’s complement of 13250 is 86750.


Therefore:
M = 72532
10’s complement of N =+86750
Sum=159282

Discard end carry 105= - 100000


Answer = 59282

93
Example
Example22

Now consider an example with M <N.


The subtraction 13250 - 72532 produces negative 59282. Using the
procedure with complements, we have

M = 13250
10’s complement of N = +27468
Sum = 40718

Take 10’s complement of Sum = 100000


-40718
The number is : 59282
Place negative sign in front of the number: -59282

94

You might also like