BCD-code


Schematic representation of BCD codes

A BCD code (English: abbreviation for binary coded decimal) is a binary code to store decimal numbers. Each digit of the number is encoded by a group of four bits which are a binary representation of the relevant figure. As a result, the hexadecimal representation of a number in BCD code looks the same as the decimal variant.

In the past, BCD encoding was widely used to simplify the electronics, especially when displaying numbers by pixel and nixie tubes and their successors, the segment segment displays. In addition, the language COBOL makes a lot of use of this code, because in an administrative environment with (yet) not so fast machines, it was easier to "highlight" a certain number from a number (BCD numbers are quite easy to convert to ASCII or EBCDIC numbers) than a binary number.

Most computer software nowadays uses other encodings, and the values ​​for (decimal) representation of numbers are usually calculated directly from these encodings. Formation of BCD code

To convert a decimal number into BCD code, each individual digit is converted to a 4 bit notation. See the following image: black boxes are bits that are "on" (1), white boxes are bits that are "off" (0).

Example: The decimal number 167 is split into 1-6-7. Each digit is converted to its binary value: 1 = 0001 6 = 0110 7 = 0111

The BCD code of 167 is thus 0001 0110 0111. Similarly, decimal 1457 in BCD code 0001 0100 0101 0111 and 16854 becomes 0001 0110 1000 0101 0100. Alternative

The use of BCD code is not efficient in memory usage (of the 16 different combinations that are 4 bit-shaped, only 10 are used) or if you need to count a lot. A variant on BCD code is the Aiken code.

wiki