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)

0 | 0000 |

1 | 0001 |

2 | 0010 |

3 | 0011 |

4 | 0100 |

5 | 0101 |

6 | 0110 |

7 | 0111 |

8 | 1000 |

9 | 1001 |

__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

+ | 1010 | A |

- | 1011 | B |

+ | 1100 | C |

- | 1101 | D |

+ | 1110 | E |

unsigned | 1111 | F |

__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

dCode retains ownership of the online "Binary Coded Decimal (BCD)" source code. Except explicit open source licence (indicated CC / Creative Commons / free), the "Binary Coded Decimal (BCD)" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "Binary Coded Decimal (BCD)" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, copy-paste, or API access for "Binary Coded Decimal (BCD)" are not public, same for offline use on PC, tablet, iPhone or Android ! Remainder : dCode is free to use.

Please, check our dCode Discord community for help requests!

NB: for encrypted messages, test our automatic cipher identifier!

- BCD Decoder/Converter
- DBC Encoder/Converter
- How to encrypt using BCD coding
- How to decrypt BCD coding
- How to recognize an BCD ciphertext?
- How to write a negative number?
- How to write a non-integer number?
- What is BCD purpose?
- What are BCD values non used in decimal representations?
- When BCD have been invented?

bcd,binary,coded,decimal,bit,packed,extended,condensed,0000,0001,0010,0011,0100,0101,0110,0111,1000,1001

Source : https://www.dcode.fr/binary-coded-decimal

© 2021 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback

▲
Thanks to your feedback and relevant comments, dCode has developed the best 'Binary Coded Decimal (BCD)' tool, so feel free to write! Thank you!