Tools to code/decode in BCD (binary coded decimal) a numeration system used in electronics and computer systems to code decimal numbers on 4 bits.
Binary Coded Decimal (BCD) - dCode
Tag(s) : Electronics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
BCD (binary coded decimal) encoding replaces directly digits 0, 1, 2, ..., 9 by their binary values (with 4 bits)
Example: To code 123, replace 1 by 0001, 2 by 0010 and 3 by 0011, so 123 is coded 0001,0010,0011 in BCD
In computers, storage is done on 8 bits, and to store BCD 4 bits on 1 byte (8 bits) is done by filling with 0 or 1 (recommended) at the beginning (storage called extended BCD, used in particular by EBCDIC)
Example: The storage of 123 in extended BCD is 11110001 11110010 11110011 (completed with 1111 at the start of the byte)
In order not to lose space, there is the packed BCD which stores 2 4-bit digits on an 8-bit byte. In addition, the condensed BCD uses the 6 unused remaining 4-bit combinations (A, B, C, D, E, F in hexadecimal) to encode the signs + and -
Example: The storage of 123 in packed BCD is 00010010 00111100 (completed with + 1100 at the end if the number of digits is odd)
There are several ways to code + and - because several variants of BCD have been proposed by computer manufacturers like IBM or Burroughs.
BCD conversion replaces each 4-bit group (packed BCD, the most common encoding) by its corresponding digit
Example: 0001 0010 0011 is decoded 1,2,3
If the code is extended BCD, the first 4 binary bits of each byte can be ignored.
The message has a length multiple of 4 and non of the 4-bits group can contain 1111.
Some systems uses 1100 for + and 1101 for -
Example: -5 is then written 1101 0101
There are different approaches to writing a non-integer (floating point) number.
The most common method is to use fixed point numbers where the point position is fixed a priori.
Example: It is decided that numbers are stored with 2decimal places (2 digits after the decimal point), then a BCD value 123 will then be read 1.23
Another method is used on some systems that use one of the non-digit values (such as 1100, 1101 or 1110) to store the position of the point.
BCD is often used in electronics, for storing or displaying numeric values. Conversion is easy, does not need a processor and is similar to peripherals such as 7-segment displays.
Another example is the storing of Dates in a BIOS of a motherboard, still today in BCD.
Also the DECIMAL format of the fields of certain databases can use this BCD coding.
Unused values are 1010, 1011, 1100, 1101, 1110, 1111
The first uses of the BCD date from a period between 1950 and 1960