0% found this document useful (0 votes)
2 views

Binary Codes - Chapter 3

Chapter 3 discusses number codes, focusing on the definitions and distinctions between analogue and digital systems, as well as encoding methods like binary coded decimal (BCD) and various types of codes. It highlights the advantages and disadvantages of binary codes, the representation of decimal numbers in BCD, and the importance of alphanumeric codes in computing. The chapter also covers the classification of digital codes, including weighted and non-weighted codes, and introduces the concept of Gray code.

Uploaded by

686qvrq69m
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Binary Codes - Chapter 3

Chapter 3 discusses number codes, focusing on the definitions and distinctions between analogue and digital systems, as well as encoding methods like binary coded decimal (BCD) and various types of codes. It highlights the advantages and disadvantages of binary codes, the representation of decimal numbers in BCD, and the importance of alphanumeric codes in computing. The chapter also covers the classification of digital codes, including weighted and non-weighted codes, and introduces the concept of Gray code.

Uploaded by

686qvrq69m
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Number Codes - Chapter 3

By Eng : Motion Marufu


E-mail: [email protected]
WhatsApp: +263773587388
Objectives
After completing this chapter, you should be able to:
 Define with the aid of examples analogue and digital systems
 Distinguish between analog and digital representations.
 Describe how information can be represented using just two states (ls and 0s).
 Cite the advantages and drawbacks of digital techniques compared with
analogue.
Number Codes
• The numbers or letters are represented as groups and are assigned specified codes
in the form of symbols that facilitate easy counting. The process of assigning
codes to numbers or words/letters is called encoding. A single symbol or a group
of symbols representing a set of numbers is known as a code. Since in digital
computing the data is stored in the form of group of bits, this method of coding is
referred to as binary code. The binary codes are classified into many sub
categories. They are as follows:
• Weighted codes
• Non-weighted codes
• Binary coded decimal code
• Alphanumeric codes
• Error detecting codes
• Error correcting codes
Binary Codes
• The classification of codes are given in Figure below.
Weighted Binary codes

Weighted binary codes obey


their positional weighting
principles. Each position of a
number represents a specific
weight. In a weighted binary
code, bits are multiplied by the
weights indicated; the sum of
these weighted bits gives the
decimal digit. The table below
gives the relationship between
decimal, binary and BCD codes.
Weighted Binary codes
• The Advantages of binary code are as follows
(i) The binary codes are suitable for the computer applications.
(ii) Binary codes make the analysis and designing of digital circuits easier since
only 0's and 1's are used.
• The Disadvantages of binary code are as follows
• The binary system requires very long string of 1s and 0s to represent the decimal
number.
Weighted And Non-weighted Codes
• Binary codes can be classified as numeric codes and alphanumeric codes.
Alphanumeric codes represent alphanumeric information, i.e. letters of the
alphabet and decimal numbers as a sequence of 0s and Is. Numeric codes
represent numeric information, i.e. only numbers as a series of 0s and Is. Numeric
codes used to represent decimal digits arc called Binary Coded Decimal (BCD)
codes.
• We are very comfortable with the decimal number system, but digital systems
force us to use the binary system. Although the binary number system has many
practical advantages and is widely used in digital computers, in many cases it is
very convenient to work with decimal especially when communication between
man and machine is extensive.
• Since most of the numeric data generated by man are in decimal numbers, to
simplify the communication process between man and machine, several systems
of numeric codes have been devised to represent decimal numbers as a series of
BCD codes.
Weighted Codes
• Weighted binary codes are those binary codes which have a specific weight for
each position of the given number. Each decimal digit of the given number is
represented as a group of 4-bit number. Several systems of the codes are used to
express the decimal digits 0 through 9. The weighted codes are 8421 code, 84-2-1
code, 2421 code, and 5211 code. The negative sign is represented as a bar on the
number.
• A BCD code is one in which the digits of a decimal number are encoded – one at a
time into groups of four binary digits. The codes combine the features of decimal
and binary numbers. In order to represent decimal digits 0, 1, 2, …., 9 it is
necessary to use a sequence of at least four binary digits. Such a sequence of
binary digits which represent a decimal digit is called a code word.
Weighted Codes
• The BCD codes may be weighted or non-weighted. The weighted codes are those
which obey the position-weighting principle. Each position of the number
represents a specific weight. For each group of four bits, the sum of weights of
those positions where the binary digit is 1 is equal to the decimal digit which the
group represents. There are several weighted codes. The weighted codes may be
positively weighted codes or negatively weighted codes.
• Positively-weighted codes are those in which all the weights assigned to the binary
are positive. There are only 17 positively weighted codes. In every positively
weighted code, the first weight must be 1, the second weight must be 1 or 2 and
the sum of all the weights must be equal to or greater than 9.
• In negatively-weighted codes, some of the weights assigned to the binary digits
must be negative. The codes 8421, 2421, 5211, 3321 and 4311 are some of
positively weighted codes.
Weighted Codes
• The codes 642-3, 631-1. 84-2-1 and 74-2-1 are some of the negatively weighted
codes. Non-weighted codes are codes, which do not obey the position weighting
principle.
Binary Coded Decimal (BCD) or 8421 Code
• The binary coded decimal code, abbreviated as BCD, is a method that uses binary
digits “0” and “1”. ON state represents “1” and OFF state represents “0”. Each
digit is called a bit. 4-bits are called a nibble and is used to represent each decimal
digit (0 through 9). This coding system has been used since the first computer.
This coding system deals with decimal and binary numbers. Each decimal number
requires 4 bits to code them. Example (51)10 is represented as 0101 0001 using
BCD code. The number of bits required to code binary numbers is more when
compared to binary coding. Despite the fact that more bits are used to represent a
decimal number in BCD code still it is convenient to use for input and output of
operations in digital systems. The code is also known as 8-4-2-1 code. This is
because 8, 4, 2, and 1 are the weights of the 4 bits of the BCD code. The 8, 4, 2, 1
code is obtained by taking the first 10 binary numbers and assigning them to the
corresponding decimal digits. The designation 8421 indicates the binary weights
of four bits (23 , 22 , 21 , 20 ).
Binary Coded Decimal (BCD) or 8421 Code
• The number 243 would be represented as 0010 0100 0011 in the 8421 code.
• There are 17 different sets of weights possible for a positively weighted code:
• (3, 3, 3, 1), (4, 2, 2, 1), (4, 3, 1, 1), (5, 2, 1, 1), (4, 3, 2, 1), (4, 4, 2, 1), (5, 2, 2, 1),
(5, 3, 1, 1), (5, 3, 2, 1), (5, 4, 2, 1), (6, 2, 2, 1), (6, 3, 1, 1), (6, 3, 2, 1), (6, 4, 2, 1),
(7, 3, 2, 1), (7, 4, 2, 1), (8, 4, 2, 1).The arithmetic operations are restricted to only
few of these codes since these arithmetic operations are very difficult in almost all
of the possible codes. The maximum decimal digit available is 910 . The binary
codes for numbers from 10 to 15 are therefore not used in BCD code..
Binary Coded Decimal (BCD) or 8421 Code
• There are ten binary combinations that represent the ten decimal digits as shown

• The BCD codes for six decimal numbers from 10 to 15 are given in Table below
These six codes are called forbidden codes and the group of these
codes is called the forbidden group in BCD code. Weights of the
numbers can be represented as negative representatives as in 8, 4,
2, 1 code. The complements of the numbers are taken for negative
representation. Thus, this is self-complementing code. Each bit is
individually complemented (by changing 1’s to 0’s and 0’s to 1’s)
and this new code word represents the complement of the digit to
which the original code word corresponds. For example, 0101
represents 3 in the 8, 4, 2, 1 code, and 1010 represents 6 in this
code. It is a weighted and self-complementing code.
Binary Coded Decimal (BCD) or 8421 Code

Advantages of BCD Codes


■ BCD coding is similar to the
binary equivalent of decimal
numbers 0–9.
■ BCD has no limitation for
number size.
■ It is easier to convert decimal
numbers from or to BCD than
to binary form.
Binary Coded Decimal (BCD) or 8421 Code
• Disadvantages of BCD Codes
• Each decimal number requires four bits to be represented in the BCD code.
• Arithmetic operations in BCD or weighted codes are much complicated as it deals
with more number of bits and also it has different set of rules.
• BCD is less efficient than binary.
• The procedure for converting a given decimal number to its BCD equivalent is as
follows:
• Step 1. Write the decimal number.
• Step 2. Convert each decimal digit to its 4-bit binary equivalent.
• Step 3. Write the binary number as an answer.
Binary Coded Decimal (BCD) or 8421 Code
• In order to illustrate the procedure, consider the conversion of decimal number 35.
Convert 2469 decimal numbers to binary-coded-
decimal (BCD) code

Encode (39584)10 into 8421 BCD number.


Solution. Given : A decimal number = 39, 584
We know that in order to convert a given decimal number to its
equivalent BCD number, we have to replace each decimal digit
by its 4-bit binary equivalent. Thus
Determination of a Decimal Number from a BCD
number
• Following is the procedure for the determination of a decimal number from a
given BCD numbers.
Step 1. Write the BCD number.
Step 2. Start at the right-most bit and
break the code into groups of four bit each.
We can add zeros at the left-most position
to complete the four-bit group.
Step 3. Convert each four-bit group to its
equivalent decimal digit.
Note that if the four-bit group is in the
range of 1010 to 1111, it is a forbidden
code group which indicates an error in the
BCD number.
Let us illustrate the procedure by
considering the BCD number 1101010001
Comparison of BCD and Binary
• It is important to realize that BCD is not another number system like binary, octal,
decimal and hexadecimal. It is, in fact, the decimal system with each digit encoded in its
binary equivalent. It is also important to understand that a BCD number is not the same
as a straight binary number. A straight binary code takes the complete decimal number
and represents it in binary; the BCD code converts each decimal digit to binary
individually. In order to illustrate this point consider the number 137 and compare its
straight binary and BCD codes.
• 13710 =0001 0011 0111 (BCD)
• 13710 =100010012 (Binary)
• The BCD code requires 12 bits while the straight binary code requires only eight bits to
represent 137. BCD requires more bits than straight binary to represent decimal numbers
of more than one digit. This is because BCD does not use all possible four-bit groups, as
pointed out earlier, and is therefore somewhat efficient.
• The main advantage of the BCD code is the relative ease of converting to and from
decimal. Only the four-bit code groups for the decimal digits 0 through 9 need to be
remembered. This case of conversion is especially important from a hardware standpoint
because in a digital system it is the logic circuits that perform the conversions to and
from decimal.
The Byte
• The byte is a group (or string) of 8-bits. The byte is very commonly used in the
field of microprocessors and microcomputers. The reason for this is that the
microprocessors and microcomputers handle and store data and information in
groups of eight bits. Thus instead of specifying the data as 8-bit, 16-bit, 32-bit etc.,
we say it as 1-byte, 2-byte, 3-byte respectively.
• It will be interesting to know that a group of four-bits is called a nibble. Hence a
byte contains two nibbles. Another point worth noting is that we need two
hexadecimal digits to represent a byte.
Alphanumeric codes
• In addition to numerical data, a computer must be able to handle non-numerical
information used in day-to-day processing. In other words, a computer should
recognize codes that represent numbers, letters of the alphabet, punctuation marks,
and other special characters. These codes are called alphanumeric codes. A
complete alphanumeric code would include the 26 lowercase letters. 26 uppercase
letters, 10 numeric digits, 7 punctuation marks, and anywhere from 20 to 40 other
characters, such as +, /, #, %, * and so on. We can say that an alphanumeric code
represents all of the various characters and functions that are found on a computer
keyboard. The most widely used alphanumeric code is the American standard
code for Information Interchange (ASCII).
Digital codes
• There are several different types of digital codes are used in digital system. All
these digital codes may be classified into different categories as follows.
1. Weighted Codes. In weighted codes each binary bit is assigned by a weight and
values depend on the position of the binary bit. The BCD code has weighted of 8, 4,
2 and 1. The bit assignment 0110, for example, is interpreted by the weights to
represent decimal 6 because 8 × 0 + 4 × 1 + 2 × 1 + 1 × 0 = 6. Weights codes are of
two types:
(a) Binary – 8421
(b) BCD
2. Non-Weighted Codes. In this category of digital code, no specific weights are
assigned to the bit position. Each digit position within the number is not assigned
fixed value. Non-weighted codes are of two types.
(a) Excess-3 (Ex-3)
(b) Gray Code
Digital codes
4. Sequential Codes. In sequential codes, each succeeding code is one binary
number greater than its preceding code. In Ex-3 code each decimal digit is obtained
by adding decimal 3 to the natural code of the digit. The sequential codes are:
(a) 8421
(b) Excess-3 (Ex-3)
• For example the Ex-3 code of binary number 0010 (decimal code 2) is obtained by
adding decimal 3 to the binary code. We add 3 to the decimal code 2 we get 5. The
binary value of 5 is 0101. Thus the Ex-3 code of the binary number 0010 is 0101.
Digital/Sequential Codes
• The Ex-3 code for decimal number 0 through 7 along with these binary equivalent
are shown in Table below.
Gray code (Unit Distance code or Reflective code)
• There are applications in which it is desirable to represent numerical as well as
other information with a code that changes in only one bit position from one code
word to the next adjacent word. This class of code is called a unit distance code
(UDC).

These are sometimes also


called as ‘cyclic’, ‘reflective’ or
‘gray’ code. These codes finds
great applications in Boolean
function minimization using
Karnaugh map. The gray code
shown in Table below is both
reflective and unit distance.
Gray Code
• The gray code was designed by Frank Gray at Bell Labs in 1953. It is an un-
weighed binary code in which two successive value differ only by one bit. The
output of many system are continuous and these data must be converted into
digital form before they are applied to a digital system.
Continuous or analog information is converted into digital
form by analog-to-digital converter. It is sometimes
convenient to use Gray code shown in Table.
The main advantage of using gray code is that only one bit
in the code group changes, from one number to the next
number. For example, from 7 to 8, the Gray code changes
from 0100 to 1100 only the first bit is changes, from 0 to 1.
The other three bits remain the same. But in binary
numbers the change from 7 to 8 will be from 0111 to 1000,
all four bits changes. The Gray code is also known as
Reflected Binary Code.
Gray code (Unit Distance code or Reflective code)
• *Gray codes are formed by reflection. The technique is as follows:
• In binary we have two digits 0 and 1.

Step I. Write 0 and 1 Step II. Write these 4 codes and again
and put a mirror, we put a mirror. The code will look in the
first see 1 and then 0. order 10, 11, 01 and 00. Then place 0’s
Place 0’s above mirror above mirror and 1’s below mirror.
and 1’s below mirror Proceeding intactively in the same
We have got gray code manner. We can form Gray code for any
for decimal digits 0 decimal digit.
through 4.
Binary to Gray conversion
• (1) Place a leading zero before the most significant bit (MSB) in the binary
number.
• (2) Exclusive-OR (EXOR) adjacent bits together starting from the left of this
number will result in the Gray code equivalent of the binary number.
• Exclusive–OR– If the two bits EX–OR’d are identical, the result is 0; if the two
bits differ, the result is 1.

• Gray to Binary conversion


• Scan the gray code word from left to right. The first 1 encountered is copied
exactly as it stands. From then on, 1’s will be written until the next 1 is
encountered, in which case a 0 is written. Then 0’s are written until the next 1 is
encountered, in which case a 1 is written, and so on.
Gray to Binary conversion
• Worked examples.

• Conversion of a Binary Number into Gray Code. Any binary number can be converted
into equivalent Gray code by the following steps:
• (i) the MSB of the Gray code is the same as the MSB of the binary number;
• (ii) the second bit next to the MSB of the Gray code equals the Ex-OR of the MSB and
second bit of the binary number; it will be 0 if there are same binary bits or it will be 1
for different binary bits;
• (iii) the third bit for Gray code equals the exclusive-OR of the second and third bits of
the binary number, and similarly all the next lower order bits follow the same
mechanism.
Conversion of Gray Code into a Binary Number
• Any Gray code can be converted into an equivalent binary number by the
following steps:
• (i) the MSB of the binary number is the same as the MSB of the Gray code;
• (ii) the second bit next to the MSB of the binary number equals the Ex-OR of the
MSB of the binary number and second bit of the Gray code; it will be 0 if there
are same binary bits or it will be 1 for different binary bits;
• (iii) the third bit for the binary number equals the exclusive-OR of the second bit
of the binary number and third bit of the Gray code, and similarly all the next
lower order bits follow the same mechanism.
Binary-to-Gray Conversion
• There are two methods of converting Gray code to Binary code. The rules for
converting from any binary number to its equivalent Gray code number are as
follows:

1. The MSB is the same in the Gray code as in the binary


number.
2. The second MSB of the Gray code is obtained by
adding the first MSB of binary number to the second MSB
of the binary number. Ignore the carry if any.
Converting binary 10110 to its cap Gray code
3. The third MSB of the Gray code is obtained by adding
equivalent is shown in Fig. 2-5. Start at the MSB
the second MSB of binary number to the third MSB of the of the binary number. The MSB of the Gray code is
binary number. Ignore the carry if any. same as the MSB of binary number, it shown by
4. Continue adding the bits as above until the LSB of Gray the download arrow. Now add the first MSB bit to
code is reached. the next MSB bit of the binary number. This is
written as the second MSB bit of the gray code.
5. The Gray code number will always have the same The procedure is continuing till the LSB bit. All
number of bits as the binary number. the procedure is shown in Fig. above with arrow.
Gray-to Binary Conversion
• The rules for converting from any binary number to its equivalent Gray code
number are as follows:
• 1. The MSB of the binary number is the same as the MSB of the Gray code
number.
• 2. The second MSB bit is obtained by adding the first MSB bit of binary number
to the second MSB bit of the Gray code number. Ignore the carry if any.
• 3. The third MSB bit is obtained by adding the second MSB bit of binary number
to the third MSB bit of the Gray code number. ignore the carry if any.
• 4. The process continues till we obtained the LSB of the binary number
Gray-to Binary Conversion
• Conversion of the 6-bit Gray code number 011011 to its 6-bit binary equivalent is
shown in Figure below
• Start at the MSB bit of the Gray code and follows the arrows. Follows the step
given procedure mentioned above. Remember that 1 + 1 = 10, the carry of 1 is
neglected the second MSB bit is obtained by adding the first MSB bit of the Gray
code number. Ignore the carry if any.
Gray Code Advantages and Disadvantages
Advantages of the Gray Code
• Only one bit changes for every addition.
• Number of bits involved is minimized as compared to the other coding forms.
• Errors during encoding can be minimized.
Limitations of the Gray Code
• It is not used in arithmetic circuits.
Applications of the Gray Code
• ■ The Gray code is used in the input and output digital signals.
• ■ The Gray code is preferred in shaft angle measuring devices as it eliminates
errors during the process.
American Standard Code for Information Interchange
(ASCII)
• The ASCII code is used for the transfer of alphanumeric information between a
computer and input/output devices such as monitors or printers. A computer also
uses it internally to store the information that an operator types in at the
computer’s keyboard.
• The ASCII code pronounced “askee is a seven-bit code, and so it has 27 (=128)
possible code groups. This is more than enough to represent all of the standard
keyboard characters as well as control functions such as the <RETURN> and
<LINEFEED> functions. Table 2-10 shows a partial list of ASCII code. You may
find it more convenient to use.
ASCII Code
• Table below shows a complete list of the ASCII code.
ASCII Code
• The table shows the definition of control abbreviations
ASCII Code
• This table is arranged in such a way that the least significant bits (LSB) appear
along a column and most-significant bits (MSB) along the horizontal row right at
the top.
• The least-significant bits (LSB) are a 4-bit group while most-significant bits
(MSB) are a 3-bit group.
• Let us see how to use this table to final the ASCII code for letter “A”. First locate
the position of “A” in the ASCII table, identify the corresponding MSB-group and
LSB-group bits. For the letter “A” we find that MSB are 100 and LSB are 0001.
Therefore,
• ASCII code for letter “A” = 100 0001
• Similarly, the ASCII code for ‘P’ is 1110000 and for ‘ESC’ is 0011011.
ASCII Code
• Example: The following is a message encoded in ASCII code. What is the message?
• 1001000 1000101 1001100 1001100 1001111
• Solution. Given : The message encoded in ASCII code.
• 1001000 1000101 1001100 1001100 1001111
• First of all, let us convert seven-bit code to its equivalent hexadecimal number. The
resulting number can be obtained as follows.

• Thus the resulting values are 4 8, 4 5, 4 C, 4 C and 4 F. Now locate these hexadecimal
values in Table 2-9 and determine the character represented by each. The results are
• “H E L L O”
• The ASCII code is used extensively to exchange information between the computer and
its peripheral devices.
ASCII Applications
• They are mainly used to give instructions to microcomputers
• It is used for interfacing devices
• It is used in the transfer of information from keyboards to computer displays and
printers
Assignment
• Represent the decimal number
• (a) 27 (b) 396 (c) 4096 in (i) binary form (ii) In ASCII Code (iii) Gray code (iv)
Excess 3 Codes.
• The following is a message encoded in ASCII code.
• 1001000 1000101 1001100 1001100 1001111
• What is the message?
Solution: Given the message encoded in the ASCII code:
1001000 1000101 1001100 1001100 1001111 1001000 Corresponds to ‘H’
We know that to read the message we have to convert the given 1000101 Corresponds to ‘E’
data string into the corresponding characters by using the 1001100 Corresponds to ‘L’
ASCII code Table. From this table we find that, 1001100 Corresponds to ‘L’
Therefore the given data string represents the message 1001111 Corresponds to ‘O’
“HELLO”
Extended Binary Coded Decimal Interchange Code
(EBCDIC)
• The second commonly used alphanumeric code is EBCDIC (Extended Binary
Coded Decimal Interchange Code), pronounced as “eb-si-dik”. This is an 8-bit
code developed by IBM mainly used in larger computers. EBCDIC code finds its
application in all IBM mainframe computer peripherals and operating systems. A
single byte in EBCDIC is divided into two 4-bit groups called nibbles. The first 4-
bit group represents the category of the character and is called the “zone”, while
the second 4-bit group identifies the specific character and is called the “digit”.
EBCDIC can correspond to 256 characters. EBCDIC does not provide any
advantage over ASCII code except that it is easier to enter data into larger
machines.
Extended Binary Coded Decimal Interchange Code
(EBCDIC)
• The EBCDIC code for first few decimal number is provided in Table 2.13.
The Excess Three (Xs-3) Code
• The Excess-3 code, also called XS-3, is a non-weighted BCD code. This code
derives its name from the fact that each binary code word is the corresponding
8421 code word plus 011(3). It is a sequential code and, therefore, can be used for
arithmetic operations. It is self-complementing code. Therefore, subtraction by the
method of complement addition is more direct in XS-3 code than that in 8421
code. The XS-3 code has six invalid states 0000 0001, 0010, 1101, 1110 and 1111.
• Excess-3 Codes
• The excess-3 code is obtained by adding (0011)2 or (3)10 to the desired 8421
code. A given decimal number is converted to its excess-3 code by adding “3” to
each decimal digit in the given number and replacing each digit of the newly
found decimal number by its 4-bit binary equivalent. The addition of “3” to a
binary digit in 8421 coded form produces a carry and is not taken forward. The
result of addition should be taken as a single entity and subsequently replaced with
its excess-3 code equivalent.
Excess-3 (XS-3) Code
• Excess-3 code is an example of unweighted code (the positional weights are not
assigned) and it is obtained by adding 3 and then converting it to a binary format.
For instance to find excess-3 representation of the decimal number 4, first 3 is
added to 4 to get 7 and then binary equivalent of 7 i.e. 0111 forms the excess-3
equivalent of 4. The table represents excess-3 equivalent of decimal numbers (0-
9).
Excess-3 code is also known as self complimenting code
or reflective code, as 1′s compliment of any number (0-9)
is available within these 10 numbers. For example 1′s
complement of 9 (1100) is 0011.
The XS-3 code words are derived from the 8421 BCD
code words adding (0011)2 or (3)10 to each code word in
8421
Excess-3 (XS-3) Code
Addition of two numbers in Excess-3 Code
Example-: To obtain an excess-3 equivalent, binary 3 needs
• 0101 (2) to be subtracted from the result as follows:
1101 (10)
• + 1000 (5)
- 0011 (3)
• --------- --------
• 1101 (10) 1010 (7)
• The result 1101 is in excess-6.
Excess-3 (XS-3) Code
• The excess-3 code is also called XS-3 code. It is non-weighted code used to
express decimal numbers. The difficulties encountered during arithmetic
operations are overcome by using excess-3 codes. This makes the excess-3 codes
significant for arithmetic operations.
• Find the Excess-3 code for the following:
(i) 24 Solution:
(i) The decimal number 24 is represented in BCD code with
(ii) (156.75)10 the individual binary equivalents. To this binary number,
(iii) 1000 1100 1010 0011 is added which results in the excess-3 code for 2410 .
2 4
0010 0100
Answer: 0101 011
The excess-3 code can also be obtained by directly adding 3
to 2 and 4. This adds up to 5 and 7. It is written in the binary
code.
Excess-3 (XS-3) Code
• (ii) (156.75)10
• The integer part is first converted into excess binary code. The excess-3 code for
151 is 0100 1011 0100. The fractional part .75 is converted by replacing 7 and 5
with the 4-bit binary equivalents of 10 and 8, respectively. The excess-3 code for
(.75)10 is (.10101000).
• Answer: (151.75)10 in Excess-3 code is 010010110100.10101000.
• (iii) The excess-3 code for the given binary number is obtained by subtracting
0011 from each 4-bit group.
• 1000 1100 1010
• 5 9 7
• The binary number thus obtained after subtraction is 0011 0100 01 Excess-3 code
is 010110010111 and its binary equivalent is 26410 .
Error Detection and Correction
• As a matter of fact, the movement of binary data and codes from one location to
another is the most frequent operation performed in digital electronic systems. For
example:
1. The transmission of digitized voice over a mobile phone
2. The storage of data in and retrieval of data from external memory devices such as
magnetic tape and disk
3. The transmission of information from a computer to a remote user terminal or
another computer over telephone lines
• Whenever information is transmitted from one electronic system (say transmitter)
to another system (say receiver), there is a possibility that errors can occur such
that the receiver does not receive the identical information that was sent by the
transmitter. The major reason for any transmission errors is electrical noise. The
noise consists of spurious fluctuations in voltage or current that are
Parity Method For Error Detection
• Error is said to be any unwanted change in the output information as compared to
the input information. In Analog systems, there is a possibility of some undesired
signals being received at the receiver. These undesired signals are referred as
noise. This causes error during signal transmission.
• On the other hand, in digital systems since the information is transferred as bits,
errors occur due to interchanging of bits. Error is produced when a bit changes
from “0” to “1” or “1” to “0” while data is transferred from one computer to
another. The process of error occurrence is as shown in Figure below. The error
caused might even corrupt the data transferred. Therefore, it is essential to check if
any error is caused during the process.
Parity Method For Error Detection
• Methods have to be evolved to keep the error in check so that once an error is
detected it has to be notified. To overcome this problem, digital devices use the
error detecting code and its correction. The error detection code is added to the
input data and if there is an error that had occurred. Many digital electronic
systems employ some method for detection (and correction) of errors. One of the
simplest and most widely used methods for error detection is the Parity Method or
the Parity code
Parity Method For Error Detection
• Parity Bit
• Strictly speaking, a Parity bit is an extra bit that is attached to a code group that is being
transmitted from one location to another. The parity bit is made either 0 or 1, depending
on the number of 1s that are contained in the code group. Two different methods are used
for attaching an extra bit. These are discussed below.
• The Even Parity Method
• In this method, the value of the parity bit is chosen so that the total number of 1s in the
code group (including the parity bit) is an even number. For example, suppose that the
code group is 1000101. This is the ASCII character “E”. The code group has three 1s.
Therefore, we will add a parity bit of 1 to make the total number of 1s an even number.
The new code group, including the parity bit, thus becomes 11000101.
• The Odd Parity Method
• In this method, the value of the parity bit is chosen so that the total number of 1s in the
code group (including the parity bit) is an odd number. For example, suppose the code
group is 1000101. The code group has three 1s. Therefore we will add a parity bit of o to
keep the total number of 1s an odd number. The new code group including the party bit
becomes 01000101.
Even and Odd Parity
• Examples for even and odd parity
Thus, the data can be corrected by setting the
parity bit. The error is identified at the
receiver by noting if there exists any change
in the parity other than the expected data. If
the receiver signal or data is expected to be of
odd parity but an even parity occurs then we
can confirm for an error. The receiver does
not take into account this byte and
retransmits the same to the transmitter.
Even and Odd Parity
• What parity do the following words have
(i) 11001101
(ii) 10110100
• Assign the proper even parity bit to the following code groups:
(a) 1010 (b) 111000 (c) 101101
• Computers often communicate with other remote computers over the telephone
lines-this is how the communication takes place over the internet. When one
computer is transmitting a message to another, the information is usually encoded
in ASCII. What actual bit strings would a computer transmit to send the message
TECHNOLOGY using ASCII with even parity.
Other error detection and correction codes
Error detection codes
1. Checksum
2.Block parity
3.Repetion
Cyclic redundant Check

Error detection and correction codes


• Hamming code

You might also like