Computer Logical Organization 简明教程

Binary Codes

在编码中,当数字、字母或单词由一组特定符号表示时,我们说该数字、字母或单词正在被编码。一组符号称为代码。数字数据表示为二进制位组并存储和传输。该组也称为 binary code 。二进制代码由数字和字母数字字母表示。

In the coding, when numbers, letters or words are represented by a specific group of symbols, it is said that the number, letter or word is being encoded. The group of symbols is called as a code. The digital data is represented, stored and transmitted as group of binary bits. This group is also called as binary code. The binary code is represented by the number as well as alphanumeric letter.

Advantages of Binary Code

以下是二进制代码提供的优点列表。

Following is the list of advantages that binary code offers.

  1. Binary codes are suitable for the computer applications.

  2. Binary codes are suitable for the digital communications.

  3. Binary codes make the analysis and designing of digital circuits if we use the binary codes.

  4. Since only 0 & 1 are being used, implementation becomes easy.

Classification of binary codes

这些代码大致分为以下四类。

The codes are broadly categorized into following four categories.

  1. Weighted Codes

  2. Non-Weighted Codes

  3. Binary Coded Decimal Code

  4. Alphanumeric Codes

  5. Error Detecting Codes

  6. Error Correcting Codes

Weighted Codes

加权二进制码是遵循权重位置原则的二进制码。数字的每个位置代表一个特定的权重。数个代码系统可用于表示十进制位数 0 到 9。在这些代码中,每个十进制位数表示为一个由四位比特组成的组。

Weighted binary codes are those binary codes which obey the positional weight principle. Each position of the number represents a specific weight. Several systems of the codes are used to express the decimal digits 0 through 9. In these codes each decimal digit is represented by a group of four bits.

weighted code

Non-Weighted Codes

在这种类型的二进制码中,不分配位置权重。非加权码的示例是 XS-3 码和格雷码。

In this type of binary codes, the positional weights are not assigned. The examples of non-weighted codes are Excess-3 code and Gray code.

Excess-3 code

XS-3 码也被称为 XS-3 码。它是一种非加权码,用于表示十进制数。XS-3 码字是从 8421 BCD 码字中派生出来的,在 8421 中,每个码字加上 (0011)2 或 (3)10。XS-3 码的获得方式如下所述 -

The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words adding (0011)2 or (3)10 to each code word in 8421. The excess-3 codes are obtained as follows −

excess3 code

Example

bcd excess3 code

Gray Code

它是非加权码,它不是算术码。这意味着没有为比特位置分配特定的权重。它有一个非常特殊的功能,即每次十进制数增加时只会改变一个比特,如图所示。由于一次仅改变一个比特,因此格雷码被称为单位距离代码。格雷码是一个循环码。格雷码不可用于算术运算。

It is the non-weighted code and it is not arithmetic codes. That means there are no specific weights assigned to the bit position. It has a very special feature that, only one bit will change each time the decimal number is incremented as shown in fig. As only one bit changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic code. Gray code cannot be used for arithmetic operation.

gray code

Application of Gray code

  1. Gray code is popularly used in the shaft position encoders.

  2. A shaft position encoder produces a code word which represents the angular position of the shaft.

Binary Coded Decimal (BCD) code

在这个码中,每个十进制位数都表示为一个 4 位二进制数。BCD 是一种用二进制码表示每个十进制位数的方法。在 BCD 中,使用四位比特,我们可以表示十六个数字(0000 到 1111)。但在 BCD 码中,只使用了前十个(0000 到 1001)。其余六个代码组合即 1010 到 1111 在 BCD 中无效。

In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.

bcd code

Advantages of BCD Codes

  1. It is very similar to decimal system.

  2. We need to remember binary equivalent of decimal numbers 0 to 9 only.

Disadvantages of BCD Codes

  1. The addition and subtraction of BCD have different rules.

  2. The BCD arithmetic is little more complicated.

  3. BCD needs more number of bits than binary to represent the decimal number. So BCD is less efficient than binary.

Alphanumeric codes

一个二进制位或比特仅能表示两个符号,因为它只有两种状态'0' 或'1'。但这对于两台计算机之间的通信是不够的,因为我们需要更多的符号进行通信。这些符号是表示 26 个大写和小写字母、0 到 9 的数字、标点符号和其他符号所必需的。

A binary digit or bit can represent only two symbols as it has only two states '0' or '1'. But this is not enough for communication between two computers because there we need many more symbols for communication. These symbols are required to represent 26 alphabets with capital and small letters, numbers from 0 to 9, punctuation marks and other symbols.

字母数字代码是表示数字和字母字符的代码。此类代码通常也会表示其他字符,如符号以及传达信息所需的各种指令。字母数字代码至少应表示字母表的 10 个数字和 26 个字母,即总共 36 个项目。以下三个字母数字代码非常普遍地用于数据表示。

The alphanumeric codes are the codes that represent numbers and alphabetic characters. Mostly such codes also represent other characters such as symbol and various instructions necessary for conveying information. An alphanumeric code should at least represent 10 digits and 26 letters of alphabet i.e. total 36 items. The following three alphanumeric codes are very commonly used for the data representation.

  1. American Standard Code for Information Interchange (ASCII).

  2. Extended Binary Coded Decimal Interchange Code (EBCDIC).

  3. Five bit Baudot Code.

ASCII 代码是 7 位代码,而 EBCDIC 是 8 位代码。ASCII 代码在世界范围内使用更普遍,而 EBCDIC 主要用于大型 IBM 计算机。

ASCII code is a 7-bit code whereas EBCDIC is an 8-bit code. ASCII code is more commonly used worldwide while EBCDIC is used primarily in large IBM computers.

Error Codes

有二进制代码技术可用于在数据传输期间检测和纠正数据。

There are binary code techniques available to detect and correct data during data transmission.

Error Code

Description

Error Detection and Correction

Error detection and correction code techniques