Monday, 6 February 2012

Binary Codes

n- Bit binary code consists of n-bits that assumes up to 2n combinations.
BCD Code:
  • 0-9 (all decimal numbers) are the digits present in the BCD code.
  • Each decimal digit is represented in 4-bits.
In a weighted code each bit position is assigned a weight such that decimal equivalent number can be obtained by adding weights of bit positions containing 1’s.
Ex: 2-4-2-1 code
1001 in 2-4-2-1 code is 2+0+0+1=3
2421: weights

Non-weighted code:
Non- weighted codes will not have weighting factor for each bit position.
Ex: excess-3 code
Self-Complementing code:
A code in which 9’s complement of a number can be obtained by simply inverting each bit in the given code.
Ex: 2-4-2-1 code, excess-3 code 
  • 456 in excess-3 code is 0111 1000 1001 
  • Complementing each bit 1000 0111 0110 which is 543 in excess-3 code.
  • 9’s complement of 456 is 543. Hence excess-3 code is self-complementing code.

Gray code:
  • In gray code only one bit changes when going from one number to immediate next number.
001- Gray code for 1
011- Gray code for 2 (only change in one bit position).
  • Gray code belongs to reflected codes. K-bit gray code can be obtained by reflecting k-1 bit gray code and prefixing ‘0’ for top code words and ‘1’ for bottom code words.
Obtaining 2-bit gray code from 1-bit gray code:

Binary to Gray code conversion:

Ex:  B3B2B1B0  = 0 1 0 1 (binary code)
      G3G2G1G0 = 0 1 1 1 (Gray code)
G3=B3, G2=B3 xor B2, G1=B2 xor B1, G0= B1 xor B0  
Gray code to binary conversion:

Ex:      G3G2G1G0 = 0 1 1 1 (Gray code)
            B3B2B1B0  = 0 1 0 1 (binary code)
B3=G3, B2=B3 xor G2, B1=B2 xor G1, B0= B1 xor G0

ASCII Code: 
  • ASCII stands for “American Standard Code for Information Interchange” 
  • It uses 7-bit code, to code 128 characters 
  • ASCII code contains 94 printable characters, and 34 non-printable characters
  • EBCDIC stands for “Extended Binary Coded Decimal Interchange Code”
  • It was used in IBM main frame computers.
  • It uses 8-bit code to represent a character.

Back                                               Contents                                              Next

No comments:

Post a Comment