|
Binary-coded decimal (BCD) encoding is a popular way in informatics and electronics to represent decimal number in Binary-code.
In this format every number's digit is represented by a binary code made up by four bits, where the value is between 0 (0000) and 9 (1001). The other six combinations can be used to represent symbols. For example number 127 is represented in BCD like this: 0001, 0010, 0111.
Because computers store data in bytes of eight bits, you can store a number for byte and fill the remaining four bits with zeros or one (as in the EBCDIC code), or put two digits per byte, packed BCD call mode. The packet BCD numbers normally end with a sign code, usually 1100 for + and 1101 for -. The number 127 is represented by 11110001, 11110010, 11110111 in EBCDIC and 00010010, 01111100 in packet BCD.
Although the BCD involves a considerable waste of bits (about 1/6 of unused memory in packed BCD), and in some cases it is preferable because it has a direct correspondence with the ASCII code. It is sufficient to replace the first four unused bits with 0011 to obtain the corresponding ASCII.
The BCD code is very popular in electronics, especially in digital circuits without microprocessor, because it facilitates the visualization of long digits of seven segment display, because each physical display corresponds exactly one digit. There are special integrated circuits that perform the conversion from BCD in the corresponding power-on sequence of segments. Even performing simple arithmetic is easier to be made of BCD digits for combinational logic circuits.
The BIOS of the personal computers store the date and time in BCD format, presumably for historical reasons.
|