Number System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Subject : Digital Fundamental

Ch-1 Binary Codes

Prepared by : Prof. Nisha Sarvaiya


EC department
Binary codes:

• In the coding, 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.

• 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

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 & 1 are being used, implementation becomes easy.
Classification of binary codes
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.
• In these codes each decimal digit is represented by a group of four bits.
Non-Weighted Codes
• In this type of binary codes, the positional weights are not assigned.
Excess-3 code
• The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express decimal
numbers.
• The Excess-3 code words are derived from the 8421 BCD code words adding (0011)2 or (3)10 to
each code word in 8421.
• The excess-3 codes are obtained as follows −
Gray Code
• It is the non-weighted code and it is not arithmetic codes.
• It has a very special feature that, only one bit will change each time the decimal number is
incremented as shown in fig.
• As only one bit changes at a time, the gray code is called as a unit distance code.
• The gray code is a cyclic code. Gray code cannot be used for arithmetic operation
• Binary to gray code conversion

• Gray to binary code conversion


Binary Coded Decimal (BCD) code
• In this code each decimal digit is represented by a 4-bit binary number.
• BCD is a way to express each of the decimal digits with a binary code.
• In the BCD, with four bits we can represent sixteen numbers (0000 to 1111).
• But in BCD code only first ten of these are used (0000 to 1001).
• The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.
Comparison with binary
• Advantages of BCD Codes
1. It is very similar to decimal system.
2. We need to remember binary equivalent of decimal numbers 0 to 9 only.

• Disadvantages of BCD Codes


1. The addition and subtraction of BCD have different rules.
2. The BCD arithmetic is little more complicated.
3. BCD needs more number of bits than binary to represent the decimal number. So
BCD is less efficient than binary.
BCD addition

• Case-1 sum is equal to or less than 9 or carry is 0.


• Case-2 sum is less than or equal to 9 but carry is 1.
• Case-3 sum is greater than 9 or carry is 0.
• Case-1 sum is equal to or less than 9 or carry is 0.

• Case-2 sum is less than or equal to 9 but carry is 1.


• Case-3 sum is greater than 9 or carry is 0.
BCD subtraction

• Step-1 obtain the 9’s complement of number B.

• Step-2 add A and 9’s complement of B.

• Step-3 if a carry is generated in step 2, then add it to the sum to obtain the final
result. The carry is called as end around carry.

• Step-4 if carry is not produced then the result is negative and hence we take the
9’s complement of the result.
Error detection and correction codes:
❖ What is Error?
• Error is a condition when the output information does not match with the input information.
• During transmission, digital signals suffer from noise that can introduce errors in the binary bits
travelling from one system to other.
• That means a 0 bit may change to 1 or a 1 bit may change to 0.

• Error-Detecting codes
• Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted.
• To avoid this, we use error-detecting codes which are additional data added to a given digital
message to help us detect if an error occurred during transmission of the message.
• A simple example of error-detecting code is parity check.
Parity Checking of Error Detection

• It is the simplest technique for detecting and correcting errors.


• The MSB of an 8-bits word is used as the parity bit and the remaining 7 bits are used as data or
message bits.
• The parity of 8-bits transmitted word can be either even parity or odd parity.

• Even parity -- Even parity means the number of 1's in the given word including the parity bit
should be even (2,4,6,....).

• Odd parity -- Odd parity means the number of 1's in the given word including the parity bit should
be odd (1,3,5,....).
Use of Parity Bit

• The parity bit can be set to 0 and 1 depending on the type of the parity required.
• For even parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is even.
Shown in fig. (a).
• For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is odd. Shown
in fig. (b).
How Does Error Detection Take Place?
• Parity checking at the receiver can detect the presence of an error if the parity of the receiver signal
is different from the expected parity.
• That means, if it is known that the parity of the transmitted signal is always going to be "even" and
if the received signal has an odd parity, then the receiver can conclude that the received signal is
not correct.
• If an error is detected, then the receiver will ignore the received byte and request for retransmission
of the same byte to the transmitter.
Error-Correcting codes

• Along with error-detecting code, we can also pass some data to figure out the original message
from the corrupt message that we received.

• This type of code is called an error-correcting code.

• Error-correcting codes also deploy the same strategy as error-detecting codes but additionally, such
codes also detect the exact location of the corrupt bit.

• In error-correcting codes, parity check has a simple way to detect errors along with a sophisticated
mechanism to determine the corrupt bit location. Once the corrupt bit is located, its value is
reverted (from 0 to 1 or 1 to 0) to get the original message.
Hamming code

You might also like