For faster navigation, this Iframe is preloading the Wikiwand page for 二进码十进数.

二进码十进数

二进码十进数(英语:Binary-Coded Decimal,简称BCD中国大陆BCD码二-十进制编码)是一种十进制数字编码的形式。在这种编码下,每个十进制数字用一串单独的二进制位元来存储与表示。常见的有以4位表示1个十进制数字,称为压缩的BCD码(compressed or packed);或者以8位表示1个十进制数字,称为未压缩的BCD码(uncompressed or zoned)。

这种编码技术,最常用于会计系统的设计里,因为会计制度经常需要对很长的数字做准确的计算。相对于一般的浮点式记数法,采用BCD码,既可保存数值的精确度,又可使电脑免除作浮点运算所耗费的时间。此外,对于其他需要高精确度的计算,BCD编码亦很常用。

BCD码的主要优点是在机器格式与人可读的格式之间转换容易,以及十进制数值的高精度表示。BCD码的主要缺点是增加了实现算术运算的电路的复杂度,以及存储效率低。

常用BCD编码方式

对应不同需求,各人亦开发了不同的编码方法,以适应不同的需求。这些编码,大致可以分成有权码无权码两种:

  1. 有权码,如:8421(最常用)、2421、5421
  2. 无权码,如:余3码、格雷码

8421码

8421码又称为BCD码,是十进制代码中最常用的一种。[1]在这种编码方式中,每一位二值代码的“1”都代表一个固定数值。将每位“1”所代表的十进制数加起来就可以得到它所代表的十进制数码。因为代码中从左至右看每一位“1”分别代表数字“8”“4”“2”“1”,故得名8421码。其中每一位“1”代表的十进制数称为这一位的权。因为每位的权都是固定不变的,所以8421码是恒权码。

余3码

余3码是由8421码加上0011形成的一种无权码,由于它的每个字符编码比相应8421码多3,故称余3码。例如,十进制字符5的余3码等于5的8421码0101加上0011,即为1000。同样,余3码中也有6种状态0000,0001,0010,1101,1110和1111是不允许出现的。 余3码也是一种对9的自补代码,因而可给运算带来方便。其次,在将两个余3码表示的十进制数相加时,能正确产生进位信号,但对“和”必须修正。修正的方法是:如果有进位,则结果加3;如果无进位,则结果减3。 余3码与十进制之间的转换也是按位进行的,值得注意的是每位十进制数的编码都应余3。

2421码

2421码是一种有权码,权值由高到低分别为2、4、2、1,特点是大于等于5的4位二进制数中最高位为1,小于5的最高位为0。如5的2421码表示为1011而不是0101。

比较

以下为三种常见的BCD编码的比较。

十进数 8421-BCD码 余3-BCD码 2421-A码
(M10 D C B A C3 C2 C1 C0 a3 a2 a1 a0
0 0 0 0 0 0 0 1 1 0 0 0 0
1 0 0 0 1 0 1 0 0 0 0 0 1
2 0 0 1 0 0 1 0 1 0 0 1 0
3 0 0 1 1 0 1 1 0 0 0 1 1
4 0 1 0 0 0 1 1 1 0 1 0 0
5 0 1 0 1 1 0 0 0 1 0 1 1
6 0 1 1 0 1 0 0 1 1 1 0 0
7 0 1 1 1 1 0 1 0 1 1 0 1
8 1 0 0 0 1 0 1 1 1 1 1 0
9 1 0 0 1 1 1 0 0 1 1 1 1

外部链接

BCD-Code页面存档备份,存于互联网档案馆

参考文献

  1. ^ Evans, David Silvester. Chapter Four: Ancillary Equipment: Output-drive and parity-check relays for digitizers. Digital Data: Their derivation and reduction for analysis and process control 1. London, UK: Hilger & Watts Ltd / Interscience Publishers. 1961-03: 46–64 [56–57] [2020-05-24].  (8+82 pages) (NB. The 4-bit 8421 BCD code with an extra parity bit applied as least significant bit to achieve odd parity of the resulting 5-bit code is also known as Ferranti code.)
{{bottomLinkPreText}} {{bottomLinkText}}
二进码十进数
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?