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

Binary-code-lecture2

The document provides an overview of binary code, including its classification into various types such as non-weighted, weighted, reflective, and error-detecting codes. It explains the conversion processes between binary and gray codes, character encoding standards like ASCII, and methods for error detection and correction, including parity checks and Hamming codes. Additionally, it discusses the representation of numbers and characters in digital systems using binary digits.

Uploaded by

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

Binary-code-lecture2

The document provides an overview of binary code, including its classification into various types such as non-weighted, weighted, reflective, and error-detecting codes. It explains the conversion processes between binary and gray codes, character encoding standards like ASCII, and methods for error detection and correction, including parity checks and Hamming codes. Additionally, it discusses the representation of numbers and characters in digital systems using binary digits.

Uploaded by

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

Binary code

• Digital data is represented, stored and transmitted as group of binary


bits.

• This group is called binary code.

• The binary code can be used for represent the number as well as alpha
numeric letters.
Classification of binary code
Binary code

Non weighted code Reflective code Sequential code Error detecting and
correcting code
•Example: •Example: •Example: •Example:
Gray 5211 8421 Hamming
Excess-3 2421 Excess-3
Weighted code Parity
Five bit BCD Excess-3

Binary • BCD
Ex: 0s1 Ex:
8421
2421
5211
4221
Binary code decimal (BCD)

• We know that decimal, octal, hexadecimal can be represented


by binary digit.

• Not only numbers but letters and other symbols can be


represented by 1s 0s.

• Combination of binary digits that represent all these things are


called digital codes.
Binary code decimal (BCD)
8421 (BCD) Decimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6

0111 7
1000 8
1001 9
Gray code
• It is called cyclic or reflected code.

• In this code each code group does not differ from its
neighbour in more than one bit.

• This code is used for input and output devices in


digital system.
Table of gray code

Decimal number Gray code


0 0 0 0 0
1 0 0 0 1
2 0 0 1 1
3 0 0 1 0
4 0 1 1 0
5 0 1 1 1
6 0 1 0 1
7 0 1 0 0
8 1 1 0 0
9 1 1 0 1
10 1 1 1 1
11 1 1 1 0
12 1 0 1 0
Conversion from binary to gray
code
Method:
• Write down binary form of the given decimal number.

• Write MSB as such.

• Then add the binary digit from left to right at the adjacent position.

• Discard carry if any.

• Write the digit which comes after addition.


Conversion from binary to gray
code

• Example:
Convert 15 into gray code.

Solution: (15)10 = (1111)2


We have to convert (1111)2 into gray code

+ + +
Left most bit 1 1 1 1

1 0 0 0

Hence the resultant gray code is 1000 for 15.


Example
– Convert (111011)2 into gray code.

Solution:

+ + + + +
Left most bit 1 1 1 0 1 1

1 0 0 1 1 0
1. Write the left most bit as such.
2. Then add the binary digit from left to right at the adjacent position.
3. Write the digit which comes after addition.

Hence the grey code of (111011)2 is 100110.


Conversion from grey code to binary
code
• Method:

1. Write the given grey code.

2. Write the left most bit as such.

3. Add this bit to the second left most bit, write the result,
discard carry.

4. Add this result to the next left most bit diagonally.


Conversion from grey code to binary
code
• Example:
Convert the following grey code into binary code from (1 0 0 0).

Solution:

We have Left most bit 1 0 0 0


+ + +

1 1 1 1

Hence the corresponding binary number us (1111) 2.


Character Codes

• Many applications of digital computers require the handling of data not only of numbers,

but also of letters.

• The most commonly used character code is ASCII (the American Standard Code for

Information Interchange).

• ASCII represents each character with a 7-bit string, yielding a total of 128 characters.

• The code contains the uppercase and lower case alphabet, numeral, punctuation, and

various nonprinting control characters.


ASCII Code
Other Codes

• Characters can be encoded according to variety standards:

– Baudot code uses 5 bits; used for teletype transmission


– ASCII (American Standard Code for Information Interchange) code uses 7 bits; used
in PCs.

– EBCDIC (Extended Binary Coded Decimal Interchange Code) uses 8 bits; used by
IBM mainframes. It is an extension of BCD code.

– Unicode and ISO10646 use 16bits; Windows NT supports Unicode.


Codes for detecting and correcting errors
• An error in a digital system is the corruption of data from its correct value to some other value.

• i.e., a change of some bits from 0 to 1 or vice versa.

• During the processing or transmission of digital data a noise may change some bits from 0 to 1 or vice versa.

• A short duration noise can affect only a single bit causes a single-bit error.

• A long duration noise can affect two or more bits causes a multi-bit error.
Codes for detecting and correcting errors
• Error-detecting codes normally add extra information to the data.

• In general, error-detecting codes contains redundant code.

• That is a code that uses n-bit strings need not contain 2n valid code words.

• An error-detecting code has the property that corrupting or garbling a code word will likely produce a bit string that is not a code word.

• Thus errors in a bit string can be detected by a simple rule - if it is not a code word it contains an error.
Parity check
• One of the most common ways to achieve error detection is by means of a parity bit.

• A parity bit is an extra bit included with a message to make the total number of 1’s transmitted either odd or even.

• If an odd parity is adopted, the P bit is chosen such that the total number of 1’s is odd.
Two dimensional codes
• LRC: Longitudinal Redundancy Checking

– LRC adds an additional character, the Block Check Character (BCC) to the end of the message or

block of data. The BCC uses parity on each bit position for each character in the message; in other words, by

determining parity on the first bit of each character and setting the first bit of the BCC to that value; then determining

parity on the second bit of each character, etc.

– Has an improved error detection rate of more than 98%.

Letter ASCII Parity Bit

D 1000100 1

A 1000001 1

T 1010100 0

A 1000001 1

BCC 1101111 1
Other codes
• Hamming codes - forward error correcting code

• CRC - cyclic-redundancy-check

• Checksum

You might also like