Sie sind auf Seite 1von 5

Binary codes

An n-bit binary code is a group of n bits that assumes up to


distinct combinations of l 's and 0 's. with each combination
representing one element of the set that is being coded . A set of
four elements can be coded with two bits. with each element
assigned one of the following bit combinations:

00 . 01. 10. 11

A set of eight elements requires a three-bit code and a set of


16 elements requires a four-bit code. The bit combination of an
n-bit code is determined from the count in binary from 0 to
. Each element must be assigned a unique binary bit
combination, and no two elements can have the same value;
otherwise, the code assignment will be ambiguous.

Although the minimum number of bits required to code


distinct quantities is n, there is no maximum number of bits that
may be used for a binary code. For example. the 10 decimal
digits can be coded with 10 bits, and each decimal digit can be
assigned a bit combination of nine 0's and a 1's . In this
particular binary code , the digit 6 is assigned the bit
combination 0001000000.

1- Gray Code

The output data of many physical systems are quantities that


are continuous. These data must be convened into digital form
before they are applied to a digital system. Continuous or analog
information is converted into digital form by means of an
analog-to-digital converter. It is sometimes convenient to use
the Gray code shown in Table l.6 represent digital data that have
been converted from analog data. The advantage of the Gray
code over the straight binary number
sequence is that only one bit in the cod e group changes in going
from one number to the next
Binary-to-Gray

Code Conversion between binary code and Gray code is useful.


The following rules explain how to convert from a binary
number to a Gray code word :
1. The most significant bit (left-most) in the Gray code is the
same as the corresponding MSB in the binary number .
2. Going from left to right, add each adjacent pair of binary
code bits to get the next Gray code bit. Discard carries .
Example

ADD bits without carry

Gray-to-Binary

Conversion To convert from Gray code to binary, use a similar


method; however, there are some differences. The following
rules apply:

1. The most significant bit (left-most) in the binary code is


the same as the corresponding bit in the Gray code.
2. Add each binary code bit generated to the Gray code bit in
the next adjacent position. Discard carries.
Example

Example

H.W

2- ASCII Code
Many applications of digital computers require the handling not
only of numbers. but also of other characters or symbols . such
as the letters of the alphabet. For instance , an insurance
company with thousands of policyholders will use a computer to
process its files. To represent the names and other pertinent
information . it is necessary to formulate a binary code for the
letters of the alphabet. In addition, the same binary code must
represent numerals and special characters (such as $).
An alphanumeric character set is a set of elements that includes
the 10 decimal digits. the 26 letters of the alphabet. and a
number of special characters . The standard binary code for the
alphanumeric characters is the American Standard Code for
Information Interchange (ASCII ), which uses seven bits 10
code 128 characters. as shown in Table 1.7

3-BCD Code

Das könnte Ihnen auch gefallen