Module 1 Part2
Module 1 Part2
6. BINARY ARITHMETIC
6.1 BINARY ADDITION
The binary addition table is as follows:
A+B SUM CARRY
0+0 0 0
0+1 1 0
1+0 1 0
1+1 0 1
Illustration 1:
Add (1010)2 and (0011)2
1010 (Augend)
0011 (Addend)
-----------------------
1101 (sum)
-----------------------
The addition manipulated above as follows.
Step 1: The least significant bits are added, i.e. 0+1 =1 with a carry of 0
Step 2: The carry in the previous is added to the next higher significant bits, i.e. 0+1+1= 0 with a carry 1.
Step 3: The carry in the previous is added to the next higher significant bits, i.e. 1+0+0 =1 with a carry 0.
Step 4: The preceding carry is added to the most significant bit i.e. 0+1+0 = 1 with a carry 0. Thus the
sum is 1101.
[Link] CODES
Binary codes are codes which are represented in binary system with modification from the original
one. The group of symbols is called as a code. The digital data is represented, stored and transmitted as
group of binary bits. This group is also called as binary code. The binary code is represented by the number
as well as alphanumeric letter.
Advantages of Binary Code
Following is the list of advantages that binary code offers.
1. Binary codes are suitable for the computer applications.
2. Binary codes are suitable for the digital communications.
3. Binary codes make the analysis and designing of digital circuits if we use the binary codes.
4. Since only 0 and 1 are being used, implementation becomes easy.
7.1 Classification of binary codes:The codes are broadly categorized into following four categories.
∙ Weighted Codes
∙ Non-Weighted Codes
∙ Binary Coded Decimal Code
∙ Alphanumeric Codes
∙ Error Codes
7.1.1 Weighted codes: Weighted binary codes are those binary codes which obey the positional weight
principle. Each position of the number represents a specific weight
Decimal 8421 5421 2421 5211
0 0000 0000 0000 0000
1 0001 0001 0001 0001
2 0010 0010 0010 0011
3 0011 0011 0011 0101
4 0100 0100 0100 0111
5 0101 1000 1011 1000
6 0110 1001 1100 1010
7 0111 1010 1101 1100
8 1000 1011 1110 1110
9 1001 1100 1111 1111
For example, in 8421BCD code, 1001 the weights of 1, 0, 0, 1 (from left to right) are 8, 4, 2 and 1
respectively. The codes 8421BCD, 2421BCD, 5211BCD are all weighted codes.
7.1.2 Non-weighted codes: The non-weighted codes are not positionally weighted. In other words, each
digit position within the number is not assigned a fixed value (or weight).
Examples are
∙ Excess-3
∙ Gray code
DECIMAL EXCESS - 3 GRAY CODE
0 0011 0000
1 0100 0001
2 0101 0011
[Link] code
Binary codes for decimal digits require a minimum of four bits. Numerous different codes can be obtained
by arranging four or more bits in ten distinct possible combinations. A few possibilities are tabulated.
[Link] detection code
In data transmission, Interference and physical defects in the communication medium can cause random bit
errors. As the signal is transmitted through a media, the signal gets corrupted because of noise and
distortion. Therefore the media is not reliable. To achieve a reliable communication through this unreliable
media, there is need for detecting the error in the signal so that suitable mechanism can be devised to take
corrective actions.
Error coding is a method of detecting and correcting these errors to ensure information is transferred intact
from its source to its destination
The errors can be divided into two types:
• Single-bit Error: only one bit of given data unit (such as a byte, character, or data unit) is changed from 1
to 0 or from 0 to 1.
• Burst Error: two or more bits in the data unit have changed from 0 to 1 or vice-versa. (Here doesn’t
necessary means that error occurs in consecutive bits)
Error Detecting Codes:
Basic approach used for error detection is the use of redundancy, where additional bits are added to
facilitate detection and correction of errors.
Popular techniques are:
• Simple Parity check
• Two-dimensional Parity check
• Checksum
• Cyclic redundancy check
Detecting Errors using simple parity check
Suppose we are transmitting 7-bit ASCII characters. A parity bit is added to each character to make it 8
bits. Parity can detect all single-bit errors
–If even parity is used and a single bit changes, it will change the parity to odd, which will be detected at
the receiver end
–The receiver end can detect the error, but cannot correct it because it does not know which bit is erroneous
Parity can also detect some multiple-bit errors
Table 1 shows the four bit data word and its corresponding code words
Decimal value Data block Parity bit Code word 0 0000 0 00000
1 0001 1 00011
2 0010 1 00101
3 0011 0 00110 4 0100 1 01001 5 0101 0 01010 6 0110 0 01100 7 0111 1
01111 8 1000 1 10001 9 1001 0 10010 10 1010 0 10100 11 1011 1 10111 12
1100 0 11000 13 1101 1 11011 14 1110 1 11101 15 1111 0 11110
Gray-to-Binary Conversion
∙ The MSB in the binary code is the same as the corresponding bit in the Gray code. ∙
Add each binary code bit generated to the Gray code bit in the next adjacent position. ∙
Discard carries.
Problem: Convert the Gray code word 11011 to binary
11. Binary-Coded Decimal Code
Although the binary number system is the most natural system for a computer because it is readily
represented in today’s electronic technology, most people are more accustomed to the decimal system. One
way to resolve this difference is to convert decimal numbers to binary, perform all arithmetic calculations in
binary, and then convert the binary results back to decimal. This method requires that we store decimal
numbers in the computer so that they can be converted to binary. Since the computer can accept only binary
values, we must represent the decimal digits by means of a code that contains 1’s and 0’s. It is also possible
to perform the arithmetic operations directly on decimal numbers when they are stored in the computer in
coded form.
A binary code will have some unassigned bit combinations if the number of elements in the set is
not a multiple power of 2. The 10 decimal digits form such a set. A binary code that distinguishes among
10 elements must contain at least four bits, but 6 out of the 16 possible combinations remain unassigned.
Different binary codes can be obtained by arranging four bits into 10 distinct combinations. This scheme is
called binary-coded decimal and is commonly referred to as BCD.
A number with k decimal digits will require 4k bits in BCD. Decimal 396 is represented in BCD
with 12 bits as 0011 1001 0110, with each group of 4 bits representing one decimal digit. A decimal
number in BCD is the same as its equivalent binary number only when the number is between 0 and 9. A
BCD number greater than 10 looks different from its equivalent binary number, even though both contain
1’s and 0’s. Note that the BCD code is not self‐complementing. Moreover, the binary combinations 1010
through 1111 are not used and have no meaning in BCD. Consider decimal 185 and its corresponding value
in BCD and binary:
(185)10 = (0001 1000 0101) BCD = (10111001)2
Table 1
In multi digit BCD coding
In this case, result (001 0001) is valid BCD number, but it is incorrect. To get the correct BCD result
correction factor of 6 has to be added to the least significant digit sum, as shown.
12.2 EBCDIC
The EBCDIC stands for Extended Binary Coded Decimal Interchange Code. IBM invented this
code to extend the Binary Coded Decimal which existed at that time. All the IBM computers and
peripherals use this code. It is an 8 bit code and therefore can accommodate 256 characters. Below is given
some characters of EBCDIC code to get familiar with it.
Hamming code is a set of error-correction code s that can be used to detect and correct bit errors
that can occur when computer data is moved or stored.
13.1 Error Detecting Codes
Basic approach used for error detection is the use of redundancy, where additional bits are added to
facilitate detection and correction of errors. Popular techniques are: • Simple Parity check • Two
dimensional Parity check • Checksum • Cyclic redundancy check
Simple Parity Checking or One-dimension Parity Check The most common and least expensive mechanism
for error- detection is the simple parity check. In this technique, a redundant bit called parity bit, is
appended to every data unit so that the number of 1s in the unit (including the parity becomes even). Blocks
of data from the source are subjected to a check bit or Parity bit generator form, where a parity of 1 is
added to the block if it contains an odd number of 1’s (ON bits) and 0 is added if it contains an even
number of 1’s. At the receiving end the parity bit is computed from the received data bits and compared
with the received parity bit, as shown in Fig 1. This scheme makes the total number of 1’s even, that is why
it is called even parity checking. Considering a 4-bit word, different combinations of the data words and the
corresponding code words are given in Table 1. Note that for the sake of simplicity, we are discussing here
the even-parity checking, where the number of 1’s should be an even number. It is also possible to use
odd-parity checking, where the number of 1’s should be odd.
Fig 1) Even parity checking scheme
Table 1:Possible 4 bit data words and corresponding code words
Two-dimension Parity Check
Performance can be improved by using two-dimensional parity check, which organizes the block of bits in
the form of a table. Parity check bits are calculated for each row, which is equivalent to a simple parity
check bit. Parity check bits are also calculated for all columns then both are sent along with the data. At the
receiving end these are compared with the parity bitcalculated on the received data. This is illustrated in
Fig. 2. Performance Two- Dimension Parity Checking increases the likelihood of detecting burst errors. As
we have shown in Fig. 2, that a 2-D Parity check of n bits can detect a burst error of n bits. A burst error of
more than n bits is also detected by 2-D Parity check with a highprobability. There is, however, one pattern
of error that remains elusive. If two bits in one data unit are damaged and two bits in exactly same position
in another data unit are also damaged, the 2-D Parity check checker will not detect an error. For example, if
two data units: 11001100 and 10101100. If first and second from last bits in each of them is changed,
making the data units as 01001110 and 00101110, the error cannot be detected by 2-D Parity check.
Fig 2) Two dimension parity checking
Example of Hamming Code Generation
Suppose a binary data 1001101 is to be transmitted. To implement hamming code for this, following steps
are used:
1. Calculating the number of redundancy bits required. Since number of data bits is 7, the value of r is
calculated as
2r > m + r + 1
24 > 7 + 4 + 1
Therefore no. of redundancy bits = 4
2. Determining the positions of various data bits and redundancy bits. The various r bits are placed at the
position that corresponds to the power of 2 i.e. 1, 2, 4, 8
References :
1. Moris Mano, “Digital Computer Fundamentals” TMH 3rd Edition
2. [Link]
3. [Link]
4. HAMMING, R. →. “Error Detecting and Error Correcting Codes.” Bell System Tech. Jour., 29
(1950): 147–160.
5. A.P GODSE,[Link] .”Digital Systems”.Technical [Link].
6. [Link]
7. [Link]
contents/IIScBANG/Digital%20Systems/Digital%[Link]
8. Digital Logic Circuits by [Link] [Link]