0% found this document useful (0 votes)
27 views46 pages

CST203 - M1 Ktunotes - in

cst203

Uploaded by

abhiramak2410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views46 pages

CST203 - M1 Ktunotes - in

cst203

Uploaded by

abhiramak2410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Number Systems
If base or radix of a number system is ‘r’, then the numbers present in that
number system are ranging from zero to r-1. The total numbers present in that
number system is ‘r’.
The following number systems are most commonly used.
• Decimal Number system
• Binary Number system
• Octal Number system
• Hexadecimal Number system

Decimal Number System


• The base or radix of Decimal number system is 10.
• numbers ranging from 0 to 9 are used.
• The part of the number that lies to the left of the decimal point is known as integer
part.
• the part of the number that lies to the right of the decimal point is known as
fractional part.

Binary Number System


• All digital circuits and systems use this binary number system.
• The base or radix of this number system is 2.
• the numbers 0 and 1 are used in this number system.
• The part of the number, which lies to the left of the binary point is known as
integer part.
• the part of the number, which lies to the right of the binary point is known as
fractional part.

Octal Number System


• The base or radix of octal number system is 8.
• numbers ranging from 0 to 7 are used in this number system.
• The part of the number that lies to the left of the octal point is known as integer

Dept of CSE| STIST| PAGE 1

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

part.
• the part of the number that lies to the right of the octal point is known as fractional
part.

Hexadecimal Number System


• The base or radix of Hexa-decimal number system is 16.
• numbers ranging from 0 to 9 and the letters from A to F are used in this number
system.
• The decimal equivalent of Hexa-decimal digits from A to F are 10 to 15.
• The part of the number, which lies to the left of the hexadecimal point is known
as integer part.
• the part of the number, which lies to the right of the Hexa decimal point is known
as fractional part.

Equivalent Decimal, Binary, Octal and Hexadecimal Numbers

Dept of CSE| STIST| PAGE 2

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Number Base Conversions


1. Decimal to Other Bases Conversion

1.1 Decimal to Binary Conversion

The following two types of operations take place, while converting decimal number into its
equivalent binary number.
• Division of integer part and successive quotients with base 2.
• Multiplication of fractional part and successive fractions with base

Example
Consider the decimal number 58.25. Here, the integer part is 58 and fractional part is 0.25.

Step 1 − Division of 58 and successive quotients with base 2.


Operation Quotient Remainder

58/2 29 0 LSB

29/2 14 1

14/2 7 0

7/2 3 1

3/2 1 1

½ 0 1 MSB

⇒5810 = 1110102
Therefore, the integer part of equivalent binary number is 111010.

Step 2 – Multiplication of 0.25 and successive fractions with base 2.


Operation Result Carry

0.25 x 2 0.5 0

0.5 x 2 1.0 1

0X2 0 0

⇒.2510 = .012
Therefore, the fractional part of equivalent binary number is .01
⇒58.2510 = 111010.012

Therefore, the binary equivalent of decimal number 58.25 is 111010.01

Dept of CSE| STIST| PAGE 3

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

1.2 Decimal to Octal Conversion

The following two types of operations take place, while converting decimal number into its
equivalent octal number.
• Division of integer part and successive quotients with base 8.
• Multiplication of fractional part and successive fractions with base 8.

Example
Consider the decimal number 58.25. Here, the integer part is 58 and fractional part is 0.25.
Step 1 − Division of 58 and successive quotients with base 8.
Operation Quotient Remainder

58/8 7 2

7/8 0 7
⇒5810 = 728
Therefore, the integer part of equivalent octal number is 72.

Step 2 − Multiplication of 0.25 and successive fractions with base 8.


Operation Result Carry

0.25 x 8 2.00 2

- 0.00 -
⇒ ..2510 = .28
Therefore, the fractional part of equivalent octal number is .2
⇒ 58.2510 = 72.28
Therefore, the octal equivalent of decimal number 58.25 is 72.2.

1.3 Decimal to Hexa-Decimal Conversion

The following two types of operations take place, while converting decimal number into its
equivalent hexa-decimal number.

• Division of integer part and successive quotients with base 16.


• Multiplication of fractional part and successive fractions with base 16.

Example
Consider the decimal number 58.25. Here, the integer part is 58 and decimal part is 0.25.
Step 1 − Division of 58 and successive quotients with base 16.

Dept of CSE| STIST| PAGE 4

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Operation Quotient Remainder

58/16 3 10=A

3/16 0 3
⇒ 5810 = 3A16
Therefore, the integer part of equivalent Hexa-decimal number is 3A.
Step 2 − Multiplication of 0.25 and successive fractions with base 16.
Operation Result Carry

0.25 x 16 4.00 4

- 0.00 -
⇒.2510 = .416
Therefore, the fractional part of equivalent Hexa-decimal number is .4.
⇒58.2510 = 3A.416
Therefore, the Hexa-decimal equivalent of decimal number 58.25 is 3A.4.

2. Binary Number to other Bases Conversion


2.1 Binary to Decimal Conversion
For converting a binary number into its equivalent decimal number, first multiply the bits of
binary number with the respective positional weights and then add all those products.
Example
Consider the binary number 1101.11.
Mathematically, we can write it as
1101.112 = (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20) + (1 × 2-1) +
(1 × 2-2)
⇒ 1101.112 = 8 + 4 + 0 + 1 + 0.5 + 0.25 = 13.75
⇒ 1101.112 = 13.7510
Therefore, the decimal equivalent of binary number 1101.11 is 13.75.

2.2 Binary to Octal Conversion

We know that the bases of binary and octal number systems are 2 and 8 respectively. Three
bits of binary number is equivalent to one octal digit, since 23 = 8.
Follow these two steps for converting a binary number into its equivalent octal number.
• Start from the binary point and make the groups of 3 bits on both sides of
binary point. If one or two bits are less while making the group of 3 bits, then
include required number of zeros on extreme sides.
• Write the octal digits corresponding to each group of 3 bits.
Example
Consider the binary number 101110.01101.

Dept of CSE| STIST| PAGE 5

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Step 1 − Make the groups of 3 bits on both sides of binary point. 101
110.011 01
Here, on right side of binary point, the last group is having only 2 bits. So, include one zero
on extreme side in order to make it as group of 3 bits.
⇒ 101 110.011 010
Step 2 − Write the octal digits corresponding to each group of 3 bits. ⇒
101110.0110102 = 56.328
Therefore, the octal equivalent of binary number 101110.01101 is 56.32.

2.3 Binary to Hexa-Decimal Conversion

We know that the bases of binary and Hexa-decimal number systems are 2 and 16 respectively.
Four bits of binary number is equivalent to one Hexa-decimal digit, since 24 = 16.
Follow these two steps for converting a binary number into its equivalent Hexa decimal
number.
• Start from the binary point and make the groups of 4 bits on both sides of binary point.
If some bits are less while making the group of 4 bits, then include required number of
zeros on extreme sides.
• Write the Hexa-decimal digits corresponding to each group of 4 bits.
Example
Consider the binary number 101110.01101
Step 1 − Make the groups of 4 bits on both sides of binary point. 10
1110.0110 1
Here, the first group is having only 2 bits. So, include two zeros on extreme side in order to
make it as group of 4 bits. Similarly, include three zeros on extreme side in order to make the
last group also as group of 4 bits.
⇒ 0010 1110.0110 1000
Step 2 − Write the Hexa-decimal digits corresponding to each group of 4 bits.
⇒ 00101110.011010002 = 2E.6816
Therefore, the Hexa-decimal equivalent of binary number 101110.01101 is 2E.68.

3. Octal Number to other Bases Conversion

3.1 Octal to Decimal Conversion

For converting an octal number into its equivalent decimal number, first multiply the digits of
octal number with the respective positional weights and then add all those products.
Example
Consider the octal number 145.23.
Mathematically, we can write it as
145.238 = (1 × 82) + (4 × 81) + (5 × 80) + (2 × 8-1) + (3 × 8-2)
⇒ 145.238 = 64 + 32 + 5 + 0.25 + 0.05 = 101.3

Dept of CSE| STIST| PAGE 6

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

⇒ 145.238 = 101.310
Therefore, the decimal equivalent of octal number 145.23 is 101.3.

3.2 Octal to Binary Conversion

The process of converting an octal number to an equivalent binary number is just opposite to
that of binary to octal conversion. By representing each octal digit with 3 bits, we will get the
equivalent binary number.
Example
Consider the octal number 145.23.
Represent each octal digit with 3 bits.
145.238 = 001100101.0100112
The value doesn’t change by removing the zeros, which are on the extreme side. ⇒
145.238 = 1100101.0100112
Therefore, the binary equivalent of octal number 145.23 is 1100101.010011.

3.3 Octal to Hexa-Decimal Conversion

Follow these two steps for converting an octal number into its equivalent Hexa decimal
number.

• Convert octal number into its equivalent binary number.


• Convert the above binary number into its equivalent Hexa-decimal number.
Example
Consider the octal number 145.23
In previous example, we got the binary equivalent of octal number 145.23
as 1100101.010011.
By following the procedure of binary to Hexa-decimal conversion, we will get
1100101.0100112 = 65.4C16
⇒145.238 = 65.4C16
Therefore, the Hexa-decimal equivalent of octal number 145.23 is 65.4C.

4. Hexa-Decimal Number to other Bases Conversion


4.1 Hexa-Decimal to Decimal Conversion
For converting Hexa-decimal number into its equivalent decimal number, first multiply the
digits of Hexa-decimal number with the respective positional weights and then add all those
products.
Example
Consider the Hexa-decimal number 1A5.2
Mathematically, we can write it as
1A5.216 = (1 × 162) + (10 × 161) + (5 × 160) + (2 × 16-1)
⇒ 1A5.216 = 256 + 160 + 5 + 0.125 = 421.125
Dept of CSE| STIST| PAGE 7

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

⇒ 1A5.216 = 421.12510
Therefore, the decimal equivalent of Hexa-decimal number 1A5.2 is 421.125.

4.2 Hexa-Decimal to Binary Conversion

The process of converting Hexa-decimal number into its equivalent binary number is just
opposite to that of binary to Hexa-decimal conversion. By representing each Hexa-decimal
digit with 4 bits, we will get the equivalent binary number.
Example
Consider the Hexa-decimal number 65.4C
Represent each Hexa-decimal digit with 4 bits.
65.4C16 = 01100101.010011002
The value doesn’t change by removing the zeros, which are at two extreme sides. ⇒
65.4C16 = 1100101.0100112
Therefore, the binary equivalent of Hexa-decimal number 65.4C is 1100101.010011.

4.3 Hexa-Decimal to Octal Conversion

Follow these two steps for converting Hexa-decimal number into its equivalent
octal number.

• Convert Hexa-decimal number into its equivalent binary number.


• Convert the above binary number into its equivalent octal number.

Example
Consider the Hexa-decimal number 65.4C
In previous example, we got the binary equivalent of Hexa-decimal number 65.4C
as 1100101.010011.
By following the procedure of binary to octal conversion, we will get
1100101.0100112 = 145.238
⇒65.4C16 = 145.238
Therefore, the octal equivalent of Hexa-decimal number 65.4C is 145.23.

Dept of CSE| STIST| PAGE 8

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Binary Arithmetic
Binary Addition

Four rules of binary addition.

In fourth case, a binary addition is creating a sum of (1 + 1 = 10) i.e. 0 is written as sum
column and 1 as carry.

Example

Binary Subtraction

There are four rules of binary subtraction.

In fourth case, 0 - 1 requires borrow of 1. After borrowing 1, 0 becomes 10. So 10 – 1, i.e. 2-


1 = 1, hence difference is 1 and borrow is 1

Dept of CSE| STIST| PAGE 9

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Example

Binary Multiplication

Example: Using the binary multiplication rules, multiply 1102 and 112.

Therefore, the product of 1102 and 112 is 100102.

Dept of CSE| STIST| PAGE 10

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Example: Using the binary multiplication rules, find the product of 110112 and 1012.
Solution:
GIven multiplicand = 11011 and multiplier = 101
On multiplying we get,

Therefore, the product of 11011 and 101 is 10000111.

Binary Division
Binary division problems can be solved by using the long division method, which is one of
the most efficient and easiest ways to divide binary numbers. These are the steps to be
followed in a binary division operation:
• Step 1: Compare the divisor with the dividend. If the divisor is larger, place 0 as
the quotient, then bring the second bit of the dividend down. If the divisor is
smaller, multiply it with 1 and the result becomes the subtrahend. Then, subtract
the subtrahend from the minuend to get the remainder.
• Step 2: Then bring down the next number bit from the dividend portion and
perform step 1 again.
• Step 3: Repeat the same process until the remainder becomes zero or the whole
dividend is divided.

Example: Consider two binary numbers, B = 011010 and C = 0101. Divide B by C.


Solution
Given: Dividend, 011010 and the divisor,C = 0101.

Dept of CSE| STIST| PAGE 11

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Step1: Since the zero in the most significant bit position doesn't change the value of the
number, let's remove it from both the dividend and divisor. So the dividend becomes 11010,
and the divisor becomes 101.

Step 2: Let us use the long-division method. In this step, compare the divisor 101 with the
first digit in the dividend 11010, since the divisor is smaller, it will be multiplied with 1 and
the result will be the subtrahend.
As per the binary multiplication rules:
• 1×1=1
• 1×0=0
• 0×1=0
• 0×0=0
So, 101 × 1 = 101, and this result is written below.
Step 3: Subtract the subtrahend 101 from the minuend 110.
As per the binary subtraction rules,
• 0 - 1 = 1, we need to borrow 1 from the next more significant bit.
• 0-0=0
• 1-1=0
• 1-0=0

When we apply the above rules, this is how the calculation is done:

• For the first digit on the right, we have to subtract (0 - 1). So, we borrow a 1 from
the digit on the left or the next higher order digit. Therefore, the result is 1.

Dept of CSE| STIST| PAGE 12

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

• Then, (0 - 0 = 0) since the number in the next higher order digit becomes 0 after
borrowing.
• 1 - 1 = 0 in the second next higher order digit.
• So, 110 - 101 = 001, and this result is written below.
Step 4: As per the rules of division, the next least significant bit comes down, and the divisor
is multiplied by 1. Since the result, 101 is bigger than the minuend 0011, this step cannot be
completed. Then, we have to go to the next step

Step 5: We write 0 as the next bit of the quotient and then, the least significant bit 0 comes
down.

Step 6: Again the divisor is multiplied by 1 and the result is written as 101 × 1 = 101.
Step 7: Now we are at the final step. As per the binary subtraction, we subtract 101 from 110.
We get, 110 - 101 = 001. The remainder is similar to Step 3, as all the numbers are the same.

The binary division operation is completed now and we get the following result.
• Quotient = 101
• Remainder = 001 = 1

Example: Evaluate 1010102 ÷ 1102 using the long-division method.

Example: Evaluate 10010112 ÷ 112 using the long-division method.

Solution:

Here, Dividend = 1001011, Divisor = 11.

Dept of CSE| STIST| PAGE 13

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Answer: Quotient = 11002, Remainder = 1

Example: Evaluate 100102÷ 112 using the long-division method.

Solution:

Here, Dividend = 100102, Divisor = 112

Dept of CSE| STIST| PAGE 14

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Answer: Quotient = 1102, Remainder = 0

Complements

Complements are used in the digital computers in order to simplify the subtraction operation
and for the logical manipulations. For each radix-r system (radix r represents base of number
system) there are two types of complements.
S.N. Complement Description

1 Radix Complement The radix complement is referred to as the r's


complement

2 Diminished Radix The diminished radix complement is referred to


Complement as the (r-1)'s complement

Diminished Radix Complement or (r-1)’s Complement

Given a number N in base r having n digits,

the (r–1)’s complement of N is defined as: (rn –1) – N

Example for 6-digit decimal numbers:

• 9’s complement is (rn – 1)–N = (106 –1)–N = 999999–N


• 9’s complement of 546700 is 999999–546700 = 453299

Example for 7-digit binary numbers:

• 1’s complement is (rn – 1) – N = (27 –1)–N = 1111111–N


• 1’s complement of 1011000 is 1111111–1011000 = 0100111

Radix Complement or r's complement


The r's complement of an n-digit number N in base r is defined as r n – N for N ≠ 0 and as 0
for N = 0.
Comparing with the (r − 1) 's complement, we note that the r's complement is obtained by
adding 1 to the (r − 1) 's complement, since r n – N = [(r n − 1) – N] + 1.

Example 1: (1011000)2

This number has a base of 2, which means it is a binary number. So, for the binary
numbers, the value of r is 2, and r-1 is 2-1=1. So, we can calculate the 1's and 2's
complement of the number.

Dept of CSE| STIST| PAGE 15

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

1's complement of the number 1011000 is calculated as:

={(27 )10-1}-(1011000)2
={(128)10-1}-(1011000)2
={(127)10}-(1011000)2
=11111112-10110002
=0100111

2's complement of the number 1011000 is calculated as:

=(27 )10-(1011000)2
=(128)10-(1011000)2
=100000002-10110002
=01010002

Example 2: (155)10

This number has a base of 10, which means it is a decimal number. So, for the decimal
numbers, the value of r is 10, and r-1 is 10-1=9. So, we can calculate the 10's and 9's
complement of the number.

9's complement of the number 155 is calculated as:

={(103 )10-1}-(155)10
=(1000-1)-155
=999-155
=(844)10

10's complement of the number 1011000 is calculated as:

=(103 )10-(15510
=1000-155
=(845)10

Example 3: (172)8

This number has a base of 8, which means it is an octal number. So, for the octal
numbers, the value of r is 8, and r-1 is 8-1=7. So, we can calculate the 8's and 7's
complement of the number.

7's complement of the number 172 is calculated as:

={(83 )10-1}-(172)8
=((512)10-1)-(132)8

Dept of CSE| STIST| PAGE 16

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

=(511)10-(122)10
=(389)10
=(605)8

8's complement of the number 172 is calculated as:

=(83 )10-(172)8
=(512)10-1728
=51210-12210
=39010
=6068

Example 4: (F9)16

This number has a base of 16, which means it is a hexadecimal number. So, for the
hexadecimal numbers, the value of r is 16, and r-1 is 16-1=15. So, we can calculate the
16's and 15's complement of the number.

15's complement of the number F9 is calculated as:

{(162 )10-1}-(F9)16
(256-1)10-F916
25510-24910
(6)10
(6)16

16's complement of the number F9 is calculated as:

{(162 )10 }-(F9)16


25610-24910
(7)10
(7)16

Binary system complements

As the binary system has base r = 2. So the two types of complements for the binary system
are 2's complement and 1's complement.

1's complement

1’s complement: is obtained by subtracting each digit in the number from 1 or by simply
inverting the digits.
The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's. This is
called as taking complement or 1's complement. Example of 1's Complement is as follows.

Dept of CSE| STIST| PAGE 17

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

2's complement

The 2's complement of binary number is obtained by adding 1 to the Least Significant Bit
(LSB) of 1's complement of the number.
2's complement = 1's complement + 1
Example of 2's Complement is as follows.

Decimal System Complements


• 9’s complement: is obtained by subtracting each digit in the number from 9 • 10’s
complement: is obtained by adding 1 to 9’s complement

Octal System Complements


• 7’s complement: is obtained by subtracting each digit in the number from 7 • 8’s
complement: is obtained by adding 1 to 7’s complement

Hexadecimal System Complements


• 15’s complement: is obtained by subtracting each digit in the number from 15(F)
• 16’s complement: is obtained by adding 1 to 15’s complement

Dept of CSE| STIST| PAGE 18

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Binary Numbers Representation

Representation of Un-Signed Binary Numbers

The bits present in the un-signed binary number holds the magnitude of a number. That means,
if the un-signed binary number contains ‘N’ bits, then all N bits represent the magnitude of the
number, since it doesn’t have any sign bit.
Example
Consider the decimal number 108. The binary equivalent of this number is 1101100. This is
the representation of unsigned binary number.
10810 = 11011002
It is having 7 bits. These 7 bits represent the magnitude of the number 108.

Representation of Signed Binary Numbers

The Most Significant Bit MSB of signed binary numbers is used to indicate the sign of the
numbers. Hence, it is also called as sign bit. The positive sign is represented by placing ‘0’ in
the sign bit. Similarly, the negative sign is represented by placing ‘1’ in the sign bit.
If the signed binary number contains ‘N’ bits, then N−1 bits only represent the magnitude of
the number since one-bit MSB is reserved for representing sign of the number.
There are three types of representations for signed binary numbers

• Sign-Magnitude form
• 1’s complement form
• 2’s complement form
Representation of a positive number in all these 3 forms is same. But, only
the representation of negative number will differ in each form.
Example
Consider the positive decimal number +108. The binary equivalent of magnitude of this
number is 1101100. These 7 bits represent the magnitude of the number 108. Since it is
positive number, consider the sign bit as zero, which is placed on left most side of magnitude.
+10810 = 011011002
Therefore, the signed binary representation of positive decimal number +108 is 01101100. So,
the same representation is valid in sign-magnitude form, 1’s complement form and 2’s
complement form for positive decimal number +108.

Sign-Magnitude form

In sign-magnitude form, the MSB is used for representing sign of the number and the
remaining bits represent the magnitude of the number. So, just include sign bit at the left most
side of unsigned binary number. This representation is similar to the signed decimal numbers
representation.

Dept of CSE| STIST| PAGE 19

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

For an n-bit number representation:

– The most significant bit (MSB) indicates sign (0: positive, 1: negative).

– The remaining (n-1) bits represent the magnitude of the number.

Decimal Signed magnitude Decimal Signed magnitude


representation in 4 representation in 4
bits bits

+0 0000 -0 1000

+1 0001 -1 1001

+2 0010 -2 1010

+3 0011 -3 1011

+4 0100 -4 1100

+5 0101 -5 1101

+6 0110 -6 1110

+7 0111 -7 1111

Note: A problem- Two different representations for zero.


Example
Consider the negative decimal number -108. The magnitude of this number is 108. We know
the unsigned binary representation of 108 is 1101100. It is having 7 bits. All these bits
represent the magnitude.
Since the given number is negative, consider the sign bit as one, which is placed on left most
side of magnitude.
−10810 = 111011002
Therefore, the sign-magnitude representation of -108 is 11101100.

1’s complement form

The 1’s complement of a number is obtained by complementing all the bits of signed binary
number. So, 1’s complement of positive number gives a negative number. Similarly, 1’s
complement of negative number gives a positive number.
That means, if you perform two times 1’s complement of a binary number including sign bit,
then you will get the original signed binary number.

Dept of CSE| STIST| PAGE 20

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Basic idea:
– Positive numbers are represented exactly as in sign-magnitude form.
– Negative numbers are represented in 1’s complement form. •

How to compute the 1’s complement of a number?


– Complement every bit of the number (1 to 0, and 0 to 1).
– Most Significant Bit (MSB) will indicate the sign of the number (0: positive, 1: negative).

Decimal 1’s complement Decimal 1’s complement


representation in 4 representation in 4
bits bits

+0 0000 -0 1111

+1 0001 -1 1110

+2 0010 -2 1101

+3 0011 -3 1100

+4 0100 -4 1011

+5 0101 -5 1010

+6 0110 -6 1001

+7 0111 -7 1000

Note: A problem- Two different representations for zero.


Advantage of 1’s complement representation:
– Subtraction can be done using addition.
– Leads to substantial saving in circuitry.

Example
Consider the negative decimal number -108. The magnitude of this number is 108. We
know the signed binary representation of 108 is 01101100.
It is having 8 bits. The MSB of this number is zero, which indicates positive
number. Complement of zero is one and vice-versa. So, replace zeros by ones and ones
by zeros in order to get the negative number.
−10810 = 100100112

Dept of CSE| STIST| PAGE 21

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Therefore, the 1’s complement of -10810 is 10010011 2.

2’s complement form

The 2’s complement of a binary number is obtained by adding one to the 1’s complement of
signed binary number. So, 2’s complement of positive number gives a negative number.
Similarly, 2’s complement of negative number gives a positive number.
That means, if you perform two times 2’s complement of a binary number including sign bit,
then you will get the original signed binary number.
Basic idea:
– Positive numbers are represented exactly as in sign-magnitude form.
– Negative numbers are represented in 2’s complement form.

How to compute the 2’s complement of a number?


– Complement every bit of the number (1 to 0 and 0 to 1), and then add one to the resulting
number.
– MSB will indicate the sign of the number (0: positive, 1: negative).

Decimal 2’s complement Decimal 2’s complement


representation in 4 representation in 4
bits bits

+0 0000 -0 -

+1 0001 -1 1111

+2 0010 -2 1110

+3 0011 -3 1101

+4 0100 -4 1100

+5 0101 -5 1011

+6 0110 -6 1010

+7 0111 -7 1001

Note: Unique representations for zero.


Advantage of 2’ s complement representation:
– Unique representation of zero.
– Subtraction can be done using addition.

Dept of CSE| STIST| PAGE 22

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

– Leads to substantial saving in circuitry.

Example
Consider the negative decimal number -108.
We know the 1’s complement of (-108)10 is (10010011)2
2’s compliment of 10810 = 1’s compliment of 10810 + 1 =
10010011 + 1
= 10010100
Therefore, the 2’s complement of 10810 is 100101002.

Subtraction with complements

1’s Complement Subtraction

• Subtraction of Smaller Number from Larger Number:

The steps for 1’s complement subtraction of a smaller number from a larger binary number
are as follows:
Step-1: Determine the 1’s complement of the smaller number.
Step-2: Add this to the larger number.
Step-3: Remove the carry and add it to the result. This carry is called end-around-carry.

Example-1: Subtract (1010)2 from (1111)2 using 1’s complement method.


Step-1: Find the 1’s complement of 1010. It will be found by replacing all 0 to 1 and all 1 to
0. In this way, the required 1’s complement will be 0101.
Step-2: In this step, we need to add the value calculated in step-1 to 1111. This is shown
below.

Dept of CSE| STIST| PAGE 23

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Note: carry 1 has been added to the addition to get the subtraction of the binary numbers.
Thus, the subtraction is done by actually adding two binary numbers.

• Subtraction of Larger Number from Smaller Number:


The steps involved in 1’s complement subtraction of a larger number from a smaller number
are as follows:
Step-1: Determine the 1’s complement of the larger number.
Step-2: Add this to the smaller number.
Step-3: The answer is the 1’s complement of the true result and opposite in sign. There is no
carry.
Example: Subtract (1010)2 from (1000)2 using 1’s complement method.
The 1’s complement of (1010)2 is (0101)2. Now, we will add this with the smaller number
and finally take 1’s complement of the result to get the answer. This is shown below.

Note: no carry has been obtained while subtracting a larger number from a smaller number.
Further, a minus sign has been put.

2’s Complement Subtraction:

• Subtraction of Smaller Number from Larger Number

To subtract a smaller number from a larger number using 2’s complement subtraction,
following steps are to be followed:
Step-1: Determine the 2’s complement of the smaller number

Dept of CSE| STIST| PAGE 24

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Step-2: Add this to the larger number.


Step-3: Omit the carry. Note that, there is always a carry in this case.
Following example illustrate the above mentioned steps:
Exampe-1: Subtract (1010)2 from (1111)2 using 2’s complement method.
Solution:
Step-1: 2’s complement of (1010)2 is (0110)2.
Step-2: Add (0110)2 to (1111)2. This is shown below.

• Subtraction of Larger Number from Smaller Number:


To subtract a larger number from a smaller number using 2’s complement subtraction,
following steps are to be followed:
Step-1: Determine the 2’s complement of the smaller number
Step-2: Add this to the larger number.
Step-3: There is no carry in this case. The result is in 2’s complement form and is negative.
Step-4: To get answer in true form, take 2’s complement and change its sign.
xample-2: Subtract (1010)2 from (1000)2 using 2’s complement.
Solution:
Step-1: Find the 2’s complement of (1010)2. It is (0110)2.
Step-2: Add (0110)2 to (1000)2.

Dept of CSE| STIST| PAGE 25

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Advantages:
Though both 1’s and 2’s complement method for subtracting binary numbers seems to be
complicated when compared with direct method of subtraction of two binary numbers, both
have advantage when applied using logic circuits, because they allow subtraction to be done
using only addition. The 1‘s and 2’s complement of a binary number can easily be arrived at
using logic circuits; the advantage in 2’s complement subtraction is that the end-around-carry
operation present in 1’s complement method is not involved here.

BCD or Binary Coded Decimal

• BCD or Binary Coded Decimal is that number system or code which has the binary
numbers or digits to represent a decimal number.
In BCD we can use the binary number from 0000-1001 only, which are the decimal
equivalent from 0-9 respectively.
• if a number have single decimal digit then it’s equivalent Binary Coded Decimal will be
the respective four binary digits of that decimal number
• if the number contains two decimal digits then it’s equivalent BCD will be the respective
eight binary of the given decimal number. Four for the first decimal digit and next four
for the second decimal digit.
• Let, (12)10 be the decimal number whose equivalent Binary coded decimal will be
00010010. Four bits from L.S.B is binary equivalent of 2 and next four is the binary
equivalent of 1.

Dept of CSE| STIST| PAGE 26

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

• For 0 to 9 decimal numbers both binary and BCD is equal but when decimal number is
more than one bit BCD differs from binary.
Decimal number Binary number Binary Coded Decimal(BCD)
0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
10 1010 0001 0000
11 1011 0001 0001
12 1100 0001 0010
13 1101 0001 0011
14 1110 0001 0100
15 1111 0001 0101

BCD Addition

• Step 1: Add the two BCD numbers, using the rules for binary addition.
• Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
• Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is
generated, it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the six
invalid BCD code words and return the code to 8421. If a carry results when 6 is
added, simply add the carry to the next 4-bit group.

Example 1: Find the sum of the BCD numbers 01000011 + 00110101

Solution:

Decimal number of the given BCD numbers are as below:

01000011BCD = 4310

00110101BCD = 3510

Dept of CSE| STIST| PAGE 27

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

In the above example, all the 4-bit BCD additions generate valid BCD number, that means
less than 9. So, the final correct result is 7810 = 01111000BCD.

Example 2: Find the sum of the BCD numbers 01110101 + 00110101

Solution:

Decimal number of the given BCD numbers are as below:

01110101BCD = 7510

00110101BCD = 3510

both the BCD code addition generated result larger than 9, so invalid. To get the correct
result, we added 6 (01102) to both the invalid sum. Notice that the carry generated from the
left group is forwarded to the right group. The final correct result is 11010 =
000100010000BCD.

BCD Subtraction
9’s Complement Method
• Find the 9’s complement of the subtrahend
• Add it to the minuend using BCD addition
• If result is invalid BCD, add 6 (0110)
• Shift carry to next bit

Dept of CSE| STIST| PAGE 28

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

• If end around carry is generated add carry to the result, otherwise find the 9’s complement
of the result.
Example: Solve BCD Subtraction using 9’s Complement Method 987.6 – 678.9
Solution
o Find the 9’s complement of the subtrahend 678.9
9 9 9. 9
+ 6 7 8. 9
3 2 1. 0

o Add it to the minuend using BCD addition


1 1 1 1 1
987.6 1 0 0 1 1 0 0 0 0 1 1 1. 0 1 1 0
321.0 + 0 0 1 1 0 0 1 0 0 0 0 1. 0 0 0 0

1 1 0 0 1 0 1 0 1 0 0 0. 0 1 1 0
invalid invalid valid valid

o If result is invalid BCD, add 6 (0110)



1 1 1
1 1 0 0 1 0 1 0 1 0 0 0. 0 1 1 0
+ 0 1 1 0 0 1 1 0

1 0 0 1 0 1 0 0 0 0 1 0 0 0. 0 1 1 0

o Shift carry to next bit


0 0 1 0 0 0 0 0 1 0 0 0. 0 1 1 0
+ 1 1

0 0 1 1 0 0 0 0 1 0 0 0. 0 1 1 1
3 0 8. 7

o no end around carry is generated


Answer: 987.6 – 678.9 = 308.7

10’s Complement Method


• Find the 10’s complement of a negative number
• Add two numbers using BCD addition
• If carry is not generated find the 10s Complement of the result , and assign negative sign
• If end around carry is generated, discard carry

Dept of CSE| STIST| PAGE 29

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Example: Solve BCD Subtraction using 10’s Complement Method 987.6 – 678.9
Solution
o Find the 10’s complement of the subtrahend 678.9

9 9 9. 9
+ 6 7 8. 9
3 2 1. 0
+ 1

3 2 1. 1

o Add it to the minuend using BCD addition


1 1 1 1 1
987.6 1 0 0 1 1 0 0 0 0 1 1 1. 0 1 1 0
321.1 + 0 0 1 1 0 0 1 0 0 0 0 1. 0 0 0 1

1 1 0 0 1 0 1 0 1 0 0 0. 0 1 1 1
invalid invalid valid valid

o If result is invalid BCD, add 6 (0110)

1 1 1
1 1 0 0 1 0 1 0 1 0 0 0. 0 1 1 1
+ 0 1 1 0 0 1 1 0

1 0 0 1 0 1 0 0 0 0 1 0 0 0. 0 1 1 1

o Discard end around carry and Shift carry to next bit

0 0 1 0 0 0 0 0 1 0 0 0. 0 1 1 1
+ 1 0 0

0 0 1 1 0 0 0 0 1 0 0 0. 0 1 1 1
3 0 8. 7

Answer: 987.6 – 678.9 = 308.7

Example: Solve BCD Subtraction using 10’s Complement Method 26.25 – 38.26
Solution
o Find the 10’s complement of the subtrahend 38.26

Dept of CSE| STIST| PAGE 30

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

9 9. 9 9
+ 3 8. 2 6
6 1. 7 3
+ 1

6 1. 7 4

o Add it to the minuend using BCD addition


1 1 1 1 1
26.25 0 0 1 0 0 1 1 0. 0 0 1 0 0 1 0 1
61.74 + 0 1 1 0 0 0 0 1. 0 1 1 1 0 1 0 0

1 0 0 0 0 1 1 1. 1 0 0 1 1 0 0 1
8 valid 7 valid 9 valid 9 valid

o all results is valid BCD


o carry is not generated, find the 10s Complement of the result, and assign
negative sign

9 9. 9 9
+ 8 7. 9 9
1 2. 0 0
+ 1

1 2. 0 1

Answer: 26.25 – 38.26 = - 12.01

Octal Addition
Example: Solve 4568 - 1238
Solution

4 5 6
+ 1 2 3
? ? ?

Dept of CSE| STIST| PAGE 31

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

6+3 = 9 = (8x1) + 1
5+2+1 = 8 = (8x1) + 0
4+1+1 = 6

1 1
4 5 6
+ 1 2 3
6 0 1

Answer: 4568 - 1238 = 6018

Octal Subtraction

1. General Method

Example
7438 - 5648

7 4 3
- 5 6 4

3-4 cannot be done, so borrow from preceeding 4,


4<6, so borrow from preceeding 7
So 7 becomes 6

6 8 8 8+3-4= 7
7 4 3 8+4-6= 5
- 5 6 4 6-5= 1
______
1 5 7

7438 - 5648 = 1578

2. 7’s Complement Method


Steps
1. Find 7’s complement of Subtrahend
2. Add Minuend to 7’s complement of Subtrahend
3. If carry is generated, add carry to result. If no carry, find 7”s complement of
result and assign negative sign

Example: Solve 7438 - 5648


1. Find 7’s complement of Subtrahend 564

7 7 7
-5 6 4
_______

Dept of CSE| STIST| PAGE 32

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

2 1 3
2. Add Minuend 743 to 7’s complement of Subtrahend (213)

7 4 3
+ 2 1 3
1 1 5 6
7+2= 9 = (8 X 1) + 1
3. carry is generated, add carry to result.
1 5 6
+ 1
1 5 7

Answer: 7438 - 5648 = 1578

3 8’s Complement Method

4. Find 8’s complement of Subtrahend


5. Add Minuend to 8’s complement of Subtrahend
6. If carry is generated, discard carry. If no carry, find 8”s complement of result and
assign negative sign

Example
7438 - 5648
1. Find 8’s complement of Subtrahend 564
▪ Find 7’s complement of Subtrahend 564

7 7 7
-5 6 4
_______
2 1 3
▪ Add 1 to 7’s complement 213
2 1 3
+ 1
2 1 4

2. Add Minuend 743 to 8’s complement of Subtrahend (214)

7 4 3
+ 2 1 4
1 1 5 7

7+2= 9 = (8 X 1) + 1

3. carry is generated, discard carry


Answer = 7438 - 5648 = 1578

Dept of CSE| STIST| PAGE 33

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Hexadecimal Addition

Example: Solve 4A616 – 1B316


Solution

4 A 6
+ 1 B 3
? ? ?

6+3 = 9
A+B = 10+11= 21 = (16X1) + 5
4+1+1 = 6

1
4 A 6
+ 1 B 3
6 5 9

Answer: 4A68 – 1B316 = 65916

Hexadecimal Subtraction

1. General Method

Example
Solve 974B16 – 587C16

9 7 4 B
- 5 8 7 C
? ? ? ?

B-C requires borrow. Borrow from MSB 9

8 15 15 16
9 7 4 B
- 5 8 7 C
? ? ? ?
A=10, B= 11. C=12, D=14, F=15
16+11-12= 15 = F
15+4-7= 12= C
Dept of CSE| STIST| PAGE 34

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

15+7-8= 14= E
8-5 =3

8 15 15 16
9 7 4 B
- 5 8 7 C
3 E C F

Answer: 974B16 – 587C16 = 3ECF16

2. 15’s Complement Method


Steps
a. Find 15’s complement of Subtrahend
b. Add Minuend to 15’s complement of Subtrahend
c. If carry is generated, add carry to result. If no carry, find 15’s complement of
result and assign negative sign

Example #1: Solve 974B16 – 587C16


Solution:
a. Find 15’s complement of Subtrahend
F F F F
- 5 8 7 C
? ? ? ?
A=10, B= 11. C=12, D=14, F=15

F-C = 15-12 = 3
F-7 = 15-7 = 8
F-8 = 15-8 = 7
F-5 = 15-5 = 10 = A
F F F F
- 5 8 7 C
A 7 8 3

b. Add Minuend to 15’s complement of Subtrahend


9 7 4 B
+ A 7 8 3

? ? ? ?

B+3 = 11+3 = 14 = E
4+8=12= C
7+7=14= E
9+A=9+10=19=(16X1) + 3
9 7 4 B
+ A 7 8 3

Dept of CSE| STIST| PAGE 35

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

1 3 E C E

c. carry is generated, add carry to result.


3 E C E
+ 1
3 E C F

Answer: 974B16 – 587C16 = 3ECF16

Example #2: Solve 97116 –CB116


Solution:
a. Find 15’s complement of Subtrahend
F F F
- C B 1
? ? ?
A=10, B= 11. C=12, D=14, F=15

F-1 = 15-1 = 14 = E
F-B=15-11=4
F-C=15-12=3
F F F
- C B 1
3 4 E

b. Add Minuend to 15’s complement of Subtrahend


9 7 1
+ 3 4 E

? ? ?

E+1 = F
7+4= 11= B
9+3= 12= C

9 7 1
+ 3 4 E

C B F

c. no carry, find 15’s complement of result and assign negative sign

F F F
- C B F
? ? ?

Dept of CSE| STIST| PAGE 36

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

F-F = 0
F-B= 15- 11 = 4
F-C = 15-12 = 3

F F F
- C B F
3 4 0

Answer: 97116 – CB116 = -34016

3. 16’s Complement Method


Steps
a. Find 16’s complement of Subtrahend
b. Add Minuend to 16’s complement of Subtrahend
c. If carry is generated, discard carry. If no carry, find 16’s complement of result
and assign negative sign

Example
Solve 974B16 – 587C16

a. Find 16’s complement of Subtrahend

Find 15’s complement of Subtrahend


F F F F
- 5 8 7 C
? ? ? ?
A=10, B= 11. C=12, D=14, F=15

F-C = 15-12 = 3
F-7 = 15-7 = 8
F-8 = 15-8 = 7
F-5 = 15-5 = 10 = A
F F F F
- 5 8 7 C
A 7 8 3

Find 16’s complement of Subtrahend

A 7 8 3
+ 1
A 7 8 4

b. Add Minuend to 15’s complement of Subtrahend


9 7 4 B

Dept of CSE| STIST| PAGE 37

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

+ A 7 8 4

? ? ? ?

B+4 = 11+4 = 15 = F
4+8=12= C
7+7=14= E
9+A=9+10=19=(16X1) + 3
9 7 4 B
+ A 7 8 3

1 3 E C F

c. If carry is generated, discard carry.


3 E C E
+ 1
3 E C F

Answer: 974B16 – 587C16 = 3ECF16

Example #2: Solve 97116 –CB116


Solution:
a. Find 16’s complement of Subtrahend
Find 15’s complement of Subtrahend

F F F
- C B 1
? ? ?
A=10, B= 11. C=12, D=14, F=15

F-1 = 15-1 = 14 = E
F-B=15-11=4
F-C=15-12=3
F F F
- C B 1
3 4 E
Find 16’s complement of Subtrahend

3 4 E
+ 1
3 4 F

a. Add Minuend to 15’s complement of Subtrahend


9 7 1
+ 3 4 F

Dept of CSE| STIST| PAGE 38

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

? ? ?

F+1 = 16 = (16X1)+0
1+7+4= 12= C
9+3= 12= C

1
9 7 1
+ 3 4 F

C C 0

b. no carry, find 16’s complement of result and assign negative sign


find 15’s complement of result
F F F
- C C 0
? ? ?

F-0 = F
F-C= 15- 12 = 3
F-C = 15-12 = 3

F F F
- C C 0
3 3 F

find 16’s complement of result


1
3 3 F
+ 1
3 4 0

Answer: 97116 – CB116 = -34016

Binary Codes
When numbers, letters or words are represented by a specific group of symbols, it is
said that the number, letter or word is being encoded. The group of symbols is called as a
code.

Classification of binary codes


Binary codes are broadly categorized into following categories.
• Weighted Codes
• Non-Weighted Codes

Dept of CSE| STIST| PAGE 39

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Weighted Codes
Weighted binary codes are those binary codes which obey the positional weight principle.
Each position of the number represents a specific weight. Several systems of the codes are
used to express the decimal digits 0 through 9 (like 8421, 2421 and 84-2-1). In these codes
each decimal digit is represented by a group of four bits.
Weighted codes can be further classified as positively weighted codes (8421, 2421) and
negatively weighted codes (84-2-1).

Non-Weighted Codes
In this type of binary codes, the positional weights are not assigned. The examples of non-
weighted codes are Excess-3 code and Gray code.

8 4 2 1 code

• The weights of this code are 8, 4, 2 and 1.


• This code has all positive weights. So, it is a positively weighted code.
• This code is also called as natural BCD code.
Example
Let us find the BCD equivalent of the decimal number 786. This number has 3 decimal digits
7, 8 and 6. From the table, we can write the BCD 84218421 codes of 7, 8 and 6 are 0111,
1000 and 0110 respectively.
∴ 78610 = 011110000110BCD
There are 12 bits in BCD representation, since each BCD code of decimal digit has 4 bits.

2 4 2 1 code

• The weights of this code are 2, 4, 2 and 1.


• This code has all positive weights. So, it is a positively weighted code.
• It is an unnatural BCD code. Sum of weights of unnatural BCD codes is equal to 9.
• It is a self-complementing code. Self-complementing codes provide the 9’s complement
of a decimal number, just by interchanging 1’s and 0’s in its equivalent 2421
representation.
Example
Let us find the 2421 equivalent of the decimal number 786. This number has 3 decimal digits
7, 8 and 6. From the table, we can write the 2421 codes of 7, 8 and 6 are 1101, 1110 and 1100
respectively.
Therefore, the 2421 equivalent of the decimal number 786 is 110111101100.

8 4 -2 -1 code

• The weights of this code are 8, 4, -2 and -1.


• This code has negative weights along with positive weights. So, it is a negatively
weighted code.

Dept of CSE| STIST| PAGE 40

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

• It is an unnatural BCD code.


• It is a self-complementing code.
Example
Let us find the 8 4-2-1 equivalent of the decimal number 786. This number has 3 decimal
digits 7, 8 and 6. From the table, we can write the 8 4 -2 -1 codes of 7, 8 and 6 are 1001, 1000
and 1010 respectively.
Therefore, the 8 4 -2 -1 equivalent of the decimal number 786 is 100110001010.

Excess 3 code

• This code doesn’t have any weights. So, it is an un-weighted code.


• We will get the Excess 3 code of a decimal number by adding three 0011 to the binary
equivalent of that decimal number. Hence, it is called as Excess 3 code.
• It is a self-complementing code.
Example
Let us find the Excess 3 equivalent of the decimal number 786. This number has 3 decimal
digits 7, 8 and 6. From the table, we can write the Excess 3 codes of 7, 8 and 6 are 1010, 1011
and 1001 respectively.
Therefore, the Excess 3 equivalent of the decimal number 786 is 101010111001
Example 1: Decimal number 31
1. We find the BCD code of each digit of the decimal number.
Digit BCD
3 0011
1 0001
2) Then, we add 0011 in both of the BCD code.

Decimal BCD Excess-3


3 0011+0011 0110
1 0001+0011 0100
3. So, the excess-3 code of the decimal number 31 is 0110 0100

Example 2: Decimal number 81.61


• We find the BCD code of each digit of the decimal number.

Digit BCD
8 1000

Dept of CSE| STIST| PAGE 41

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

1 0001
6 0110
1 0001
• Then, we add 0011 in both of the BCD code.

Decimal BCD Excess-3


8 1000+0011 1011
1 0001+0011 0100
6 0110+0011 1001
• So, the excess-3 code of the decimal number 81.61 is 1011 0100.1001 0100

Self-complementary property
A self-complementary binary code is a code which is always complimented in itself. By
replacing the bit 0 to 1 and 1 to 0 of a number, we find the 1's complement of the number.
The sum of the 1'st complement and the binary number of a decimal is equal to the binary
number of decimal 9.

Binary Codes for Decimal digits

The following table shows the various binary codes for decimal digits 0 to 9.
Decimal Digit 8421 Code 2421 Code 84-2-1 Code Excess 3 Code

0 0000 0000 0000 0011

1 0001 0001 0111 0100

2 0010 0010 0110 0101

3 0011 0011 0101 0110

4 0100 0100 0100 0111

5 0101 1011 1011 1000

6 0110 1100 1010 1001

7 0111 1101 1001 1010

8 1000 1110 1000 1011

9 1001 1111 1111 1100

Dept of CSE| STIST| PAGE 42

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Gray Codes

The Gray Code is a sequence of binary number systems, which is also known as reflected
binary code. The reason for calling this code as reflected binary code is the first N/2 values
compared with those of the last N/2 values in reverse order. In this code, two consecutive values
are differed by one bit of binary digits. Gray codes are used in the general sequence of
hardware-generated binary numbers. These numbers cause ambiguities or errors when the
transition from one number to its successive is done. This code simply solves this problem by
changing only one bit when the transition is between numbers is done.

The gray code is a very light weighted code because it doesn't depend on the value of the digit
specified by the position. This code is also called a cyclic variable code as the transition of one
value to its successive value carries a change of one bit only.

Binary to Gray conversion:


1. The Most Significant Bit (MSB) of the gray code is always equal to the MSB of
the given binary code.
2. Other bits of the output gray code can be obtained by XORing binary code bit at
that index and previous index.

Gray to binary conversion:


1. The Most Significant Bit (MSB) of the binary code is always equal to the MSB
of the given gray code.
2. Other bits of the output binary code can be obtained by XORing gray code bit at
that index and previous binary code bit.

Dept of CSE| STIST| PAGE 43

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

Decimal Number Binary Number Gray Code


0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000

Error Detection and Correction Code

Error detection and correction code plays an important role in the transmission of data from
one source to another. The noise also gets added into the data when it transmits from one system
to another, which causes errors in the received binary data at other systems. The bits of the data
may change (either 0 to 1 or 1 to 0) during transmission.

It is impossible to avoid the interference of noise, but it is possible to get back the original data.
For this purpose, we first need to detect either an error z is present or not using error detection
codes. If the error is present in the code, then we will correct it with the help of error correction
codes

Error detection code

Dept of CSE| STIST| PAGE 44

Downloaded from Ktunotes.in


CST203| LOGIC SYSTEM DESIGN| MODULE 1 NOTES

The error detection codes are the code used for detecting the error in the received
data bitstream. In these codes, some bits are included appended to the original bitstream.

Error detecting codes encode the message before sending it over the noisy channels. The
encoding scheme is performed in such a way that the decoder at the receiving can find the
errors easily in the receiving data with a higher chance of success.

Parity Code

In parity code, we add one parity bit either to the right of the LSB or left to the MSB to the
original bitstream. On the basis of the type of parity being chosen, two types of parity codes
are possible, i.e., even parity code and odd parity code.

Error correction code

Error correction codes are generated by using the specific algorithm used for removing and
detecting errors from the message transmitted over the noisy channels. The error-correcting
codes find the correct number of corrupted bits and their positions in the message. There are
two types of ECCs(Error Correction Codes), which are as follows.

Block codes

in block codes, in fixed-size blocks of bits, the message is contained. In this, the redundant bits
are added for correcting and detecting errors.

Hamming Code

Hamming code is an example of a block code. The two simultaneous bit errors are detected,
and single-bit errors are corrected by this code. In the hamming coding mechanism, the sender
encodes the message by adding the unessential bits in the data. These bits are added to the
specific position in the message because they are the extra bits for correction.

Dept of CSE| STIST| PAGE 45

Downloaded from Ktunotes.in

You might also like