HCBBS Forum (English)
Submit Chemical Projects / Find Solutions
Amplify Your Requirements on a Broader Chemical Platform *Engineering · Technology · Equipment · Solutions*
Submit Request

BCD code

2009-03-20View Original

Thread Content

That is, BCD code. Binary-Coded Decimal, abbreviated as BCD, is also known as BCD code or binary-decimal code; it is alternatively referred to as binary numeral system for decimal numbers. It is a binary digital encoding format, representing decimal codes in binary form. This encoding format uses four bits to store a decimal digit, enabling fast conversion between binary and decimal forms. This coding technique is most commonly used in the design of accounting systems, as accounting systems often need to perform accurate calculations on long sequences of numbers. Compared to ordinary floating-point notation, using BCD code allows for the preservation of numerical accuracy while also avoiding the time consumption associated with floating-point calculations by computers. Furthermore, BCD encoding is also commonly used for other calculations that require high precision. Since decimal numbers use ten digits: 0, 1, 2, …, 9, at least 4 binary digits are required to represent 1 decimal digit. A 4-bit binary code has 2^4=16 possible combinations. Out of these 16 codes, any 10 can be chosen to represent 10 decimal digits, with a total of N=16! /(16-10)! It is approximately equal to 2.9 times 10 to the 10th power possible solutions. The commonly used BCD codes are listed at the end. The most common BCD encoding method is the one that uses the binary representations of the ten digits from “0” to “9” to represent values. This coding method is called “8421 code” in mainland China. In addition, to meet various needs, different people have also developed different coding methods to suit those needs. These codes can be roughly divided into weighted and unweighted codes: weighted BCD codes, such as 8421 (the most commonly used), 2421, 5421…; unweighted BCD codes, such as remainder-3 code, Gray code… Below is a comparison of three common BCD coding schemes. Decimal 8421 – BCD code: Remainder 3 – BCD code: 2421 – Code A (M10): D C B A C3 C2 C1 C0 a3 a2 a1 a0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 1 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 6 0 1 1 0 1 0 0 1 0 1 1 0 7 0 1 1 1 1 0 1 0 0 1 1 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 What is BCD code? 2006-3-19 13:24:45 BCD code, also known as 8421 code, involves converting decimal numbers into binary form using the 8421 format. As we know, decimal numbers are composed of 10 digits from 0 to 9, and each of these digits has its own corresponding 8421 code: 0 = 0000, 1 = 0001, 2 = 0010, 3 = 0011, 4 = 0100, 5 = 0101, 6 = 0110, 7 = 0111, 8 = 1000, 9 = 1001. For example, the 8421 code for 321 is 3 2 1 0011 0010 0001. The reason is as follows: 0011 = 8×0 + 4×0 + 1×2 + 1×1 = 3; 0010 = 8×0 + 4×0 + 2×1 + 1×0 = 2; 0001 = 8×0 + 4×0 + 2×0 + 1×1 = 1. In detail, BCD code represents decimal numbers in binary form, but it differs from ordinary binary conversion in that each decimal digit from 0 to 9 corresponds to a four-digit binary code. The corresponding relationships are as follows: Decimal 0 corresponds to binary 0000; decimal 1 corresponds to binary 0001; …… 9 corresponds to binary 1001. The number 10 is represented by two such codes: 00010000. In BCD code, a carry occurs when the sequence 1001 appears, unlike in ordinary binary code where a carry occurs only when 1111 appears. For example, the binary unsigned number 11101010, when converted into a three-digit uncompressed BCD number in the order of hundreds, tens, and units, should be __C__. A. 00000001 00000011 00000111    B. 00000011 00000001 00000111 C. 00000010 00000011 00000100    D. 00000011 00000001 00001001 Solution: (1) 11101010 converted to decimal is 234. (2) Arranged in the order of hundreds, tens, and units, it should be __C__. Note: Difference between compressed BCD code and uncompressed BCD code — Each digit in a compressed BCD code is represented by 4 binary digits, with one byte representing two decimal digits. For example, 10010110B represents the decimal number 96D ; Uncompressed BCD code uses 1 byte to represent one decimal digit; the top four bits are always 0000, and the lower 4 bits range from 0000 to 1001, representing values from 0 to 9. For example, 00001000B represents the decimal number 8.

Submit a Project

**Looking for Chemical Technology, Equipment & Solutions?** No Registration Required Broader Platform Exposure | Global Chemical Service Provider Connections

Submit Request — Free Consultation

Disclaimer

This is an automated machine translation of the original thread. Some technical terms may have inaccuracies; the original text shall prevail. Click "View Original" at the top right to access the source page, which supports IP-based automatic real-time language translation. Please watch out for contact details and sales inducements to prevent fraud. All content and translations are for reference only, representing solely the poster's personal views. For enquiries, email service@hcbbs.com.