BCD

Binary-Coded Decimal (BCD)

Binary-Coded Decimal (BCD), in computer science, is a standard for representing decimal numbers in the binary system, where each decimal digit is encoded with a sequence of 4 bits

With this special coding of the decimal digits in the binary system, Arithmetic operations such as addition, subtraction, multiplication, and division can be performed

Each decimal digit has a binary representation coded with 4 bits:

Decimal BCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

The decimal numbers, are coded in BCD with the bits that represent their digits

Example: BCD encoding of decimal number 59237

Decimal BCD
5 0101
9 1001
2 0010
3 0011
7 0111

Definition

In BCD each digit that represents a decimal digit (0, 1,… 8 and 9) is represented by its equivalent binary in four bits (nibble or quartet)

Since nine is the number highest that can be represented in BCD

The following table shows the most commonly used BCD codes:

Decimal Natural Aiken Excess 3
0 0000 0000 0011
1 0001 0001 0100
2 0010 0010 0101
3 0011 0011 0110
4 0100 0100 0111
5 0101 1011 1000
6 0110 1100 1001
7 0111 1101 1010
8 1000 1110 1011
9 1001 1111 1100

The BCD only uses 10 of the 16 possible combinations that can be formed with numbers of 4 bits, so the system loses representation capacity, although it facilitates the compression of the numbers

This is because BCD is only used to represent the digits, no the numbers in its entirety

This means that for numbers more than one figure requires two numbers BCD

A simple way to calculate numbers in BCD it is usually adding bit to bit, and if the set of 4 bits exceeds the number 9, then is added a 6 (0110) in binary, to be able to start over, as if we were doing a module to the summand

Since computer systems began to store data in sets of eight bits (octet), there are two common ways to store BCD data:

  • Omission of the four bits (as is the case in the EBCDIC)
  • Storage of two BCD data; it is the so called "packaged" BCD, in which the sign is also included first, usually with 1100 for the + and 1101 for the –

In this way, the number 127 would be represented as (11110001, 11110010, 11110111) in the EBCDIC or (11000001, 00100111) in the packaged BCD

BCD is still widely used to store data, in binary arithmetic or in electronics

The numbers can be easily displayed on seven segment viewers by sending each BCD quartet to a viewer

A personal computer's BIOS usually stores the date and time in BCD format; probably for historical reasons the need for its conversion into ASCII was avoided

The advantage of BCD code over rendering classic binary is that there is no limit to the size of a number

The numbers that are represented in binary are generally limited by the number greater than can be represented with 8, 16, 32 or 64 bits

Conversely, using BCD, add a new digit it only involves adding a new sequence of 4 bits

Convert from Decimal To XS3 (Excess 3)

The conversion of decimal numbers to excess 3 (XS3) is made by successively adding 3 to each digit

The resulting amount is converted to binary

Example: Convert Decimal 67 to XS3

We take every digit and we add 3

Number Result
6 9
7 10

To the digits resulting we convert them into binary

Digit Binary
9 1001
10 1010

So we have to:

67_{(10} = 1001\hspace{2mm}1010_{(XS3}

BCD in electronics

BCD is very common in electronic systems where a numerical value must be displayed, especially in non programmed digital systems (without a microprocessor or microcontroller)

Using the BCD code, the manipulation of the numerical data to be displayed is simplified, for example in a seven segment viewer

This in turn leads to a simplification in the physical design of the circuit (hardware)

If the numerical quantity were stored and manipulated in natural binary, the circuit would be much more complex than if the BCD were used

There is a program called b1411 that is used to divide the binary system in two combinations

Una por ejemplo es la de sistemas digitales

IBM and BCD

IBM used the terms decimal encoded in binary and BCD, for the binary code of six bits with which they could be represented numbers, capital letters, and special characters

A variant of the BCD was used on most of IBM's early computers, including IBM1620 and IBM 1400

With the introduction of the System/360, the BCD was replaced by EBCDIC, of eight bits

The positions of the bits, in the BCD of six bits, they were generally labeled B, A, 8, 4, 2 and 1

To encode the numeric digits, A and B were zero

The letter A was coded as (B, A, 1), etc

Legal History

In 1972, the U.S. Supreme Court overturned a lower court's decision that had allowed a patent to convert numbers BCD encoded to binary on a computer

This was one of the first important cases to determine the patentability of software and algorithms employees in the same