Vous êtes sur la page 1sur 5

GOVERNMENT POST GRADUATE COLLEGE

SAMANANAD FAISALABAD

ELE-401

M. Sameer Sajjad

Roll #306

Submitted to: Miss Fizza


Binary Codes
Definition:

‘Any discrete element of information distinct among a group of quantities can be


represented by a Binary Code.’

For example ‘Red’ is one distinct colour of the spectrum. The letter ‘A’ is one distinct letter
of the Alphabet.

Basically a binary code is an arrangement of bits (0 and 1) that is used to feed information to
the computer, as the only understandable language of a computer is Binary (0s and 1s).

Binary codes can only be obtained by arranging the bits in the form of 2n, where ‘n’ is the
number of bits to be used, and 2n is the number of digits that are to be coded.

For example, if we were to code the first 8 digits, then 2n=8 and n=3, that means the total
number of bits that are to be used is 3.

But if we were to code the digits upto 10, as 10 can’t be represented in the form of 2n, then
we take the next possible number of digits, that is 16, as 24=16, the number of bits that are
to be used will be 4, so we use 3 bits to code the first 8 digits and the 4th bit is left
unassigned or ‘0’ and then use 4 bits to represent the next digits upto 10, and the rest of the
digits upto 15 are left unassigned as well.

So in order to give any information to a computer, it is first converted into a Binary code and
then fed to the computer. Similarly when some information is to be taken from the
computer, it is first received in the form of Binary and then converted into human
understandable languages.

Types of Binary Codes:

• Decimal Codes
• Error Detection Codes
• The Reflected Code
• Alphanumeric Codes

Decimal Codes:

The binary codes that are used to represent Decimal Digits (0-9) are also called ‘Decimal-
codes’.

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.

For example,

8421 (BCD), 84-2-1, 2421, 4281, 8142, Excess-3, 5043210 (Biquinary)


Decimal 8421 Excess-3 84-2-1 2421 5043210
Digit (BCD) (BCD+3) (Biquinary)
0 0000 0011 0000 0000 0100001
1 0001 0100 0111 0001 0100010
2 0010 0101 0110 0010 0100100
3 0011 0110 0101 0011 0101000
4 0100 0111 0100 0100 0110000
5 0101 1000 1011 1011 1000001
6 0110 1001 1010 1100 1000010
7 0111 1010 1001 1101 1000100
8 1000 1011 1000 1110 1001000
9 1001 1100 1111 1111 1010000

➢ The BCD code is simply obtained by arranging 4 bits and then giving distinct values of 0
and 1 to each bit, it can represent all the decimal values (0-9).
➢ The Excess-3 code is obtained by adding 3 in each of the respective decimal digit of BCD.
That means if we add 3 into 4, we obtain 7, and the binary of 7 will be placed against 4 in
the Excess-3 code, similarly if we add 3 to 9, we obtain 11, and the binary of 11 is placed
against 9 in the Excess-3 code.
➢ The 84-2-1 and 2421 codes are obtained exactly the same way as BCD.
➢ Although the Biquinary code (5043210) is obtained the same way as the rest of the
codes, but it is a bit improved, as it has the ability of error recognition. As you can see
from the code, that each value of code has two 1s and five 0s in it, so when a receiving
machine receives the codes, it makes sure that the code has the same number of 1s and
0s, but if somehow some error occurs during the transmission and the code is changed,
then the machine can detect that by checking if it doesn’t have two 1s or five 0s in it.

Difference between coding and conversion in Binary;

It is to be noted that the Conversion of a Decimal into Binary and the Coding of a Decimal
into Binary are two completely different things, Although in BCD both are the same as long
as the decimal digit is between 0-9, but as we move forward, both the terms become
different.

For example if we had a decimal digit 15, then its conversion into binary will be 1111, but if
we were to represent it in a Binary code like BCD, it will be represented as 00010101.
Because the binary of 1 is 0001 and that of 5 is 0101, so 15 becomes (0001)1(0101)5

Both of the terms have their own usage. For example if we were to perform some
calculation, we give the number in decimal which is then converted into Binary and after the
calculation, the computer returns it back to us after converting it back to decimal.

But if we were to send some information, say some Alphabets like K, it will first be
converted into a decimal number which is then converted into a binary code and sent
forward. And the opposite happens at the receiving end.
Conversion of Binary to BCD;

Any binary number can be converted into a BCD code by adding the binary of '6’ to that
number.

Although this doesn’t hold true for the numbers between ‘0-9’ because the binary and BCD
of these numbers is the same.

But the binary of any number out of this range can be converted to BCD by the above
mentioned method.

When we add the binary of '6’ to any other number, we obtain a number that has more
then 4 bits in it, this number can then be divided into groups of 4 bits, and this new number
will be the BCD of the respective binary number.

Error-Detection Codes:

As we know that whenever a message is transferred from one computer to another, it is


always done through a communication medium. So there is a chance that there might be
some disturbance in the communication medium and it may change the value of the
message being transmitted. That means it may change any values of 1’s to 0’s or vice versa.

So ‘Error-Detection’ codes are the codes that help detect an error during communication.
These codes can tell the receiving machine if the code was changed during transmission. If
the error occurs only at random intervals and has no known cause, it may be just ignored
and the faulty message can be transmitted again. But if the errors occur more frequently
due to some malfunction in the system. It has to be removed before any further
transmission of data.

Error-Detection codes work by adding a Parity bit to the code of the message that is being
transmitted. The parity bit (P) serves as the basis for error detection. The bit is added to the
rest of the code in two ways, it can either be added to make the total sum of all the 1’s in
the code equal to an odd value or it can be added to the code to make the total sum of all
the 1’s in the code equal to an even value.

“So a parity bit (P) is an extra bit included with a message to make the total number of 1’s
either odd or even.”

Message (a) P (odd) Message (b) P (even)

0000 1 0000 0
0001 0 0001 1
0010 0 0010 1
0011 1 0011 0
0100 0 0100 1
0101 1 0101 0
0110 1 0110 0
0111 0 0111 1
1000 0 1000 1
1001 1 1001 0
1010 1 1010 0
1011 0 1011 1
1100 1 1100 0
1101 0 1101 1
1110 0 1110 1
1111 1 1111 0

As you can see from the table, in the message (a), the parity bit is added to make the sum of
1’s equal to an odd number. And in the message (b) the parity bit is added to make the sum
of all the 1’s equal to some even number.

This addition of parity bits to the message is done by passing the message from the sending
computer through a parity-generation network, where the required P is added. Then after
the transmission of this message over the communication medium, before it is received by
the receiving computer, it is first fed to a parity-check network, which checks the code
according to the adopted parity scheme (even or odd). In this way any error in the message
can be detected.

But this parity check method can only detect any odd combination of errors and is not able
to detect even combination of errors. Meaning it can only detect 1, 3, 5, 7, 9… number of
errors and can’t detect 2, 4, 6, 8... number of errors.

The reason for that is; Parity is an XOR function, it really just tells us if there are an odd or
even number of 1’s. If a single bit changes, it turns odd to even, or vice versa. If two change
the parity would remain the same. As for the first error say it changes from odd to even, but
then for the second error, it will change back to odd from even. In the end its value remains
the same, we can never detect whether there was an error in the transmission.

Vous aimerez peut-être aussi