New Document
 Electronics Electronics Catlog DIC Catlog

 Number System Conversions Between Number System Arithematic Operations 1's & 2's Complement Gray Codes Arithmetic Circuits Logical Gates and Truth Table Funtions Boolean Expressions Boolean Algebra Karnaugh Map Multiplexer DeMultiplexer Encoder & Decoder TTL Circuits Multivibrators 555 Timer Flip Flops RS Flip - Flop JK Flip - Flop D Flip - Flop Shift Register Schmitt Trigger Asynchronous Counters Synchronous Counters Digital - Analog Conversion Data Flow ROM Memory Drives Electronics Equation Resistor Color Codes

## Codes

Digital circuits are inherently binary in nature, but several types of representations of numerical data are in use.

The representation of an unsigned integer can be done in binary, octal, decimal or hexadecimal. For display purposes, each decimal digit is often represented by a four-bit binary number in a system called binary coded decimal (BCD). Conversions between these representations can be handled in a routine manner. ### Alphanumeric Coding

For the inherently binary world of the computer, it is necessary to put all symbols, letters, numbers, etc. into binary form. The most commonly used alphanumeric code is the ASCII code, with others like the EBCDIC code being applied in some communication applications.

### EBCDIC Alphanumeric Code

The extended binary coded decimal interchange code (EBCDIC) is an 8-bit alphanumeric code which has been extensively used by IBM in its mainframe applications.

### BCDIC Code Table

 Char EBCDIC HEX A 110 0001 C1 B 110 0010 C2 C 110 0011 C3 D 110 0100 C4 E 110 0101 C5

### ASCII Alphanumeric Code

The American Standard Code for Information Interchange (ASCII) is the standard alphanumeric code for keyboards and a host of other data interchange tasks. Letters, numbers, and single keystroke commands are represented by a seven-bit word. Typically a strobe bit or start bit is sent first, followed by the code with LSB first. Being a 7-bit code, it has 2^7 or 128 possible code groups ### ASCII Alphanumeric Code Table

 Char 7 bit ASCII HEX A 100 0001 41 B 100 0010 42 C 100 0011 43 D 100 0100 44 E 100 0101 45

### Parity Checks

Errors in digital code will result in the changing of a 0 to a 1 or vice versa. One helpful method for determining if a single error of that type has occurred is to check the evenness or oddness of the sum of the set bits. To facilitate this check an extra bit called the parity bit is added to each word in a data transmission. In the even-parity method the parity bit is chosen so that the total number of 1s including the parity bit is even. The receiver checks the parity to detect any single-bit errors. The same thing can be accomplished with an odd-parity method, so it is necessary to know which is being used in order to communicate with a host computer. It will also be necessary to know how many data bits and how many stop bits are being used.

### Binary Coded Decimal

One of the most widely used representations of numerical data is the binary coded decimal (BCD) form in which each integer of a decimal number is represented by a 4-bit binary number (see conversion table). It is particularly useful for the driving of display devices where a decimal output is desired. BCD usually refers to such coding in which the binary digits have their normal values, i.e., 8421. Sometimes it is written "8421 BCD" to clearly distinguish it from other binary codes such as the 4221 Code, but when BCD is used without qualification, the 8421 version is assumed. ### Excess-3 Code

In this code, a digit is represented by adding 3 to the number and then converting it to a 4-bit binary number. It can be used for the representation of multi-digit decimal numbers as can BCD. This code along with the 4221 code have some advantages for performing decimal arithmetic.

### 4221 Code

There are several codes which use binary numbers to code for single digits in multi-digit decimal numbers. This code assigns the values 4,2,2,1 instead of 8,4,2,1 to the four binary digits. It can properly be called binary coded decimal, but that designation (BCD) is usually reserved for the 8,4,2,1 code. This code is sometimes written 4221 BCD. This code along with the excess-3 code have some advantages for performing decimal arithmetic. ### Signed Integer Representations

Sign magnitude: the most significant bit is assigned to the algebraic sign. Offset binary: subtract half the largest possible number to get the value represented. I.e., you use half the largest number as the "zero" of the scale. For four bits: 2s Complement: negative integer is the complement of the positive integer plus one. ### Other Integer Representations

Binary Coded Decimal (BCD or 8421 BCD): each individual digit of the decimal number is represented by a 4-bit binary number.

2810 = 0010 1000

Excess-3: Add 3 to the number, then represent by 4-bit binary number.

2810 = 0101 1011

4221 Code: Four bits represent 4,2,2,1 instead of 8,4,2,1

2810 = 0010 1110

Gray Code: Starting at zero, make one change in the least significant possible bit to take you to the next state

2810 = 0011 1100

### Offset Binary Representation

One logical way to represent signed integers is to have enough range in binary numbers so that the zero can be offset to the middle of the range of positive binary numbers. Then the magnitude of a negative binary number can be simply subtracted from that zero point. This system has the advantage of a simple binary progression from negative to positive numbers. It is useful for binary counters and for A/D and D/A conversion. It is awkward for computation compared to the 2s complement representation.

As a simple example, consider a 4-bit binary number with maximum number 15. Subtracting 7 gives the following representation: 