To convert Decimal to BCD input decimal number in the box below, and then click on the big blue button that says “CONVERT TO BCD” and text is generated, copy it or you can download output file.
In decimal number system there only ten (10) digits from 0 to 9. Every number (value) in this decimal system represents with 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. The base of this number system is 10, because it has only 10 digits.
For Example: 8062 in decimal (base 10)
7562_{10} = (7 x 10^{3}) + (5 x 10^{2}) + (6 x 10^{1}) + (2 x 10^{0})
In BCD, numbers are represented in a decimal form, however each decimal digit is encoded using a four bit binary number.
For example: The decimal number 160 would be represented in BCD as follows:
160 = 0001 0110 0000
1 6 0
Converting a Decimal into BCD is quite simple.
Step 1: If you want to convert from decimal to BCD, simply write down the four bit binary pattern for each decimal digit.
Step 2: Now divide the number into groups of 4 bits and write down the corresponding decimal digit for each 4 bit group.
Step 3: Here are a couple of variations on the BCD representation, namely packed and unpacked. The unpacked BCD number has only a single decimal digit stored in each data byte. Here, the decimal digit will be in the low four bits and the upper 4 bits of the byte will be 0. And in the packed BCD representation, two decimal digits are placed in each byte. Mostly, the high order bits of the data byte contain the more significant decimal digit.
Example: The following is a 16 bit number encoded in packed BCD format: 01010000 10010011
This will be converted to a decimal number as follows:
0101 -> 5, 0000 -> 0, 1001 -> 9, 0011 -> 3 = 5093
DECIMAL | BCD |
---|---|
0 | 0000 |
1 | 0001 |
2 | 0010 |
3 | 0011 |
4 | 0100 |
5 | 0101 |
6 | 0110 |
7 | 0111 |
8 | 1000 |
9 | 1001 |
The use of BCD isn’t as common as binary in most computer systems because it is not as space-efficient. If we talk about packed BCD, only 10 of the 16 possible bit patterns in each 4 bit unit are used. While in unpacked BCD, only 10 of the 256 possible bit patterns in each byte are used. A 16 bit quantity can represent the range 0-65535 in binary, 0-9999 in packed BCD and only 0-99 in unpacked BCD.