bcd码二进制转十进制
Prerequisite: Number systems
先决条件: 数字系统
BCD Code (8421 Code): In BCD 8421 code, each decimal digit is represented using a 4-bit binary number. The 4-bit binary numbers have their weights attached as 8, 4, 2, 1 from MSB to LSB side. Since the weights are attached to it comes in the category of weighted codes and is also sequential.
BCD代码(8421代码) :在BCD 8421代码中 ,每个十进制数字均使用4位二进制数表示。 从MSB到LSB,4位二进制数的权重分别为8、4、2、1。 由于权重是附加的,因此它属于加权代码类别,并且是顺序的 。
In a digital system that accepts only binary numbers in form of 0 and 1, the only way to interpret decimal numbers is its conversion from decimal to binary and vice-versa which is a slow process and it also requires a huge electronic circuitry. So, we use BCD numbers. Also, the sequential nature of BCD numbers makes it advantageous for performing arithmetic operations.
在仅接受0和1形式的二进制数字的数字系统中,解释十进制数字的唯一方法是将其从十进制转换为二进制,反之亦然,这是一个缓慢的过程,并且还需要庞大的电子电路。 因此,我们使用BCD号码。 而且,BCD编号的顺序性质使其在执行算术运算时具有优势。
Although, there are many advantages there are some disadvantages too such as:
尽管有很多优点,但也有一些缺点,例如:
BCD codes are more inefficient than usual binary codes. Usually, in binary numbers, we represent (13)10 = (1101)2 i.e., we require 4-bits but in BCD notation (13)10 is represented as (0001 0011). Here, we require 8-bits to represent the same 13.
BCD代码比普通的二进制代码效率低。 通常,在二进