Binarycoded decimal
In computing and electronic systems, binarycoded decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign or for other indications (e.g., error or overflow).
In byteoriented systems (i.e. most modern computers), the term unpacked BCD^{[1]} usually implies a full byte for each digit (often including a sign), whereas packed BCD typically encodes two decimal digits within a single byte by taking advantage of the fact that four bits are enough to represent the range 0 to 9. The precise 4bit encoding may vary however, for technical reasons, see Excess3 for instance; the ten states representing a BCD decimal digit are sometimes called tetrades (for the nibble typically needed to hold them also known as tetrade) with those don't carestates unused named pseudotetrad(e)s ^{[2]}^{[3]}^{[4]}^{[5]}^{[6]} or pseudodecimal digit^{[7]}^{[8]}).^{[nb 1]}
BCD's main virtue is its more accurate representation and rounding of decimal quantities as well as an ease of conversion into humanreadable representations, in comparison to binary positional systems. BCD's principal drawbacks are a small increase in the complexity of the circuits needed to implement basic arithmetics and a slightly less dense storage.
BCD was used in many early decimal computers, and is implemented in the instruction set of machines such as the IBM System/360 series and its descendants, Digital Equipment Corporation's VAX, the Burroughs B1700, and the Motorola 68000series processors. Although BCD per se is not as widely used as in the past and is no longer implemented in newer computers' instruction sets (such as ARM; x86 does not support its BCD instructions in long mode any more), decimal fixedpoint and floatingpoint formats are still important and continue to be used in financial, commercial, and industrial computing, where subtle conversion and fractional rounding errors that are inherent in floating point binary representations cannot be tolerated.^{[9]}
Contents
 1 Basics
 2 BCD in electronics
 3 Packed BCD
 4 Zoned decimal
 5 IBM and BCD
 6 Other computers and BCD
 7 Addition with BCD
 8 Subtraction with BCD
 9 Background
 10 Legal history
 11 Comparison with pure binary
 12 Application
 13 Representational variations
 14 Alternative encodings
 15 See also
 16 Notes
 17 References
 18 Further reading
 19 External links
Basics[edit]
BCD takes advantage of the fact that any one decimal numeral can be represented by a four bit pattern; the most obvious way of encoding digits is "natural BCD" (NBCD), where each decimal digit is represented by its corresponding fourbit binary value, as shown in the following table. This is also called "8421" encoding.
Decimal digit  BCD  

8  4  2  1  
0  0  0  0  0 
1  0  0  0  1 
2  0  0  1  0 
3  0  0  1  1 
4  0  1  0  0 
5  0  1  0  1 
6  0  1  1  0 
7  0  1  1  1 
8  1  0  0  0 
9  1  0  0  1 
Other encodings are also used, including socalled "4221" and "7421"—named after the weighting used for the bits—and "Excess3".^{[10]} For example, the BCD digit 6, '0110'b in 8421 notation, is '1100'b in 4221 (two encodings are possible), '0110'b in 7421, and '1001'b (6+3=9) in excess3.
As most computers deal with data in 8bit bytes, it is possible to use one of the following methods to encode a BCD number:
 Unpacked: Each number is encoded into one byte, with four bits representing the number and the remaining bits having no significance.
 Packed: Two number are encoded into a single byte, with one number in the least significant nibble (bits 0 through 3) and the other numeral in the most significant nibble (bits 4 through 7).
As an example, encoding the decimal number 91 using unpacked BCD results in the following binary pattern of two bytes:
Decimal: 9 1 Binary : 0000 1001 0000 0001
In packed BCD, the same number would fit into a single byte:
Decimal: 9 1 Binary : 1001 0001
Hence the numerical range for one unpacked BCD byte is zero through nine inclusive, whereas the range for one packed BCD is zero through ninetynine inclusive.
To represent numbers larger than the range of a single byte any number of contiguous bytes may be used. For example, to represent the decimal number 12345 in packed BCD, using bigendian format, a program would encode as follows:
Decimal: 0 1 2 3 4 5 Binary : 0000 0001 0010 0011 0100 0101
Here, the most significant nibble of the most significant byte has been encoded as zero, so the number is stored as 012345 (but formatting routines might replace or remove leading zeros). Packed BCD is more efficient in storage usage than unpacked BCD; encoding the same number (with the leading zero) in unpacked format would consume twice the storage.
Shifting and masking operations are used to pack or unpack a packed BCD digit. Other bitwise operations are used to convert a numeral to its equivalent bit pattern or reverse the process.
BCD in electronics[edit]
This section has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
(Learn how and when to remove this template message)

BCD is very common in electronic systems where a numeric value is to be displayed, especially in systems consisting solely of digital logic, and not containing a microprocessor. By employing BCD, the manipulation of numerical data for display can be greatly simplified by treating each digit as a separate single subcircuit; this matches much more closely the physical reality of display hardware—a designer might choose to use a series of separate identical sevensegment displays to build a metering circuit, for example. If the numeric quantity were stored and manipulated as pure binary, interfacing to such a display would require complex circuitry. Therefore, in cases where the calculations are relatively simple, working throughout with BCD can lead to a simpler overall system than converting to and from binary. Most pocket calculators do all their calculations in BCD.
The same argument applies when hardware of this type uses an embedded microcontroller or other small processor. Often, smaller code results when representing numbers internally in BCD format, since a conversion from or to binary representation can be expensive on such limited processors. For these applications, some small processors feature BCD arithmetic modes, which assist when writing routines that manipulate BCD quantities.^{[11]}^{[12]}
Packed BCD[edit]
In packed BCD (or simply packed decimal), each of the two nibbles of each byte represent a decimal digit. Packed BCD has been in use since at least the 1960s and is implemented in all IBM mainframe hardware since then. Most implementations are big endian, i.e. with the more significant digit in the upper half of each byte, and with the leftmost byte (residing at the lowest memory address) containing the most significant digits of the packed decimal value. The lower nibble of the rightmost byte is usually used as the sign flag, although some unsigned representations lack a sign flag; as an example, a 4byte value consists of 8 nibbles, wherein the upper 7 nibbles store the digits of a 7digit decimal value and the lowest nibble indicates the sign of the decimal integer value.
Standard sign values are 1100 (hex C) for positive (+) and 1101 (D) for negative (−); this convention comes from the zone field for EBCDIC characters and the signed overpunch representation. Other allowed signs are 1010 (A) and 1110 (E) for positive and 1011 (B) for negative. IBM System/360 processors will use the 1010 (A) and 1011 (B) signs if the A bit is set in the PSW, for the ASCII8 standard that never passed. Most implementations also provide unsigned BCD values with a sign nibble of 1111 (F).^{[13]}^{[14]}^{[15]} ILE RPG uses 1111 (F) for positive and 1101 (D) for negative;^{[16]} these match the EBCDIC zone for digits without a sign overpunch. In packed BCD, the number 127 is represented by 0001 0010 0111 1100 (127C) and −127 is represented by 0001 0010 0111 1101 (127D). Burroughs systems used 1101 (D) for negative, and any other value is considered a positive sign value (the processors will normalize a positive sign to 1100 (C)).
Sign Digit 
BCD 8 4 2 1 
Sign  Notes 

A  1 0 1 0  +  
B  1 0 1 1  −  
C  1 1 0 0  +  Preferred 
D  1 1 0 1  −  Preferred 
E  1 1 1 0  +  
F  1 1 1 1  +  Unsigned 
No matter how many bytes wide a word is, there are always an even number of nibbles because each byte has two of them. Therefore, a word of n bytes can contain up to (2n)−1 decimal digits, which is always an odd number of digits. A decimal number with d digits requires 1/2(d+1) bytes of storage space.
For example, a 4byte (32bit) word can hold seven decimal digits plus a sign, and can represent values ranging from ±9,999,999, thus the number −1,234,567 is 7 digits wide and is encoded as:
0001 0010 0011 0100 0101 0110 0111 1101 1 2 3 4 5 6 7 −
Like character strings, the first byte of the packed decimal – that with the most significant two digits – is usually stored in the lowest address in memory, independent of the endianness of the machine.
In contrast, a 4byte binary two's complement integer can represent values from −2,147,483,648 to +2,147,483,647.
While packed BCD does not make optimal use of storage (about onesixth of the memory used is wasted), conversion to ASCII, EBCDIC, or the various encodings of Unicode is still trivial, as no arithmetic operations are required; the extra storage requirements are usually offset by the need for the accuracy and compatibility with calculator or hand calculation that fixedpoint decimal arithmetic provides. Denser packings of BCD exist which avoid the storage penalty and also need no arithmetic operations for common conversions.
Packed BCD is supported in the COBOL programming language as the "COMPUTATIONAL3" (an IBM extension adopted by many other compiler vendors) or "PACKEDDECIMAL" (part of the 1985 COBOL standard) data type, it is supported in PL/I as "FIXED DECIMAL". Besides the IBM System/360 and later compatible mainframes, packed BCD is implemented in the native instruction set of the original VAX processors from Digital Equipment Corporation and some models of the SDS Sigma series mainframes, and is the native format for the Burroughs Corporation Medium Systems line of mainframes (descended from the 1950s Electrodata 200 series).
Ten's complement representations for negative numbers offer an alternative approach to encoding the sign of packed (and other) BCD numbers. In this case, positive numbers always have a most significant digit between 0 and 4 (inclusive), while negative numbers are represented by the 10's complement of the corresponding positive number; as a result, this system allows for 32bit packed BCD numbers to range from −50,000,000 to +49,999,999, and −1 is represented as 99999999. (As with two's complement binary numbers, the range is not symmetric about zero.)
Fixedpoint packed decimal[edit]
Fixedpoint decimal numbers are supported by some programming languages (such as COBOL, PL/I and Ada); these languages allow the programmer to specify an implicit decimal point in front of one of the digits. For example, a packed decimal value encoded with the bytes 12 34 56 7C represents the fixedpoint value +1,234.567 when the implied decimal point is located between the 4th and 5th digits:
12 34 56 7C 12 34.56 7+
The decimal point is not actually stored in memory, as the packed BCD storage format does not provide for it, its location is simply known to the compiler and the generated code acts accordingly for the various arithmetic operations.
Higherdensity encodings[edit]
If a decimal digit requires four bits, then three decimal digits require 12 bits. However, since 2^{10} (1,024) is greater than 10^{3} (1,000), if three decimal digits are encoded together, only 10 bits are needed. Two such encodings are Chen–Ho encoding and densely packed decimal (DPD); the latter has the advantage that subsets of the encoding encode two digits in the optimal seven bits and one digit in four bits, as in regular BCD.
Zoned decimal[edit]
Some implementations, for example IBM mainframe systems, support zoned decimal numeric representations. Each decimal digit is stored in one byte, with the lower four bits encoding the digit in BCD form; the upper four bits, called the "zone" bits, are usually set to a fixed value so that the byte holds a character value corresponding to the digit. EBCDIC systems use a zone value of 1111 (hex F); this yields bytes in the range F0 to F9 (hex), which are the EBCDIC codes for the characters "0" through "9". Similarly, ASCII systems use a zone value of 0011 (hex 3), giving character codes 30 to 39 (hex).
For signed zoned decimal values, the rightmost (least significant) zone nibble holds the sign digit, which is the same set of values that are used for signed packed decimal numbers (see above), thus a zoned decimal value encoded as the hex bytes F1 F2 D3 represents the signed decimal value −123:
F1 F2 D3 1 2 −3
EBCDIC zoned decimal conversion table[edit]
BCD Digit  Hexadecimal  EBCDIC Character  

0+  C0  A0  E0  F0  { (*)  \ (*)  0  
1+  C1  A1  E1  F1  A  ~ (*)  1  
2+  C2  A2  E2  F2  B  s  S  2 
3+  C3  A3  E3  F3  C  t  T  3 
4+  C4  A4  E4  F4  D  u  U  4 
5+  C5  A5  E5  F5  E  v  V  5 
6+  C6  A6  E6  F6  F  w  W  6 
7+  C7  A7  E7  F7  G  x  X  7 
8+  C8  A8  E8  F8  H  y  Y  8 
9+  C9  A9  E9  F9  I  z  Z  9 
0−  D0  B0  } (*)  ^ (*)  
1−  D1  B1  J  
2−  D2  B2  K  
3−  D3  B3  L  
4−  D4  B4  M  
5−  D5  B5  N  
6−  D6  B6  O  
7−  D7  B7  P  
8−  D8  B8  Q  
9−  D9  B9  R 
(*) Note: These characters vary depending on the local character code page setting.
Fixedpoint zoned decimal[edit]
Some languages (such as COBOL and PL/I) directly support fixedpoint zoned decimal values, assigning an implicit decimal point at some location between the decimal digits of a number. For example, given a sixbyte signed zoned decimal value with an implied decimal point to the right of the fourth digit, the hex bytes F1 F2 F7 F9 F5 C0 represent the value +1,279.50:
F1 F2 F7 F9 F5 C0 1 2 7 9. 5 +0
IBM and BCD[edit]
IBM used the terms BinaryCoded Decimal Interchange Code (BCDIC, sometimes just called BCD), for 6bit alphanumeric codes that represented numbers, uppercase letters and special characters; some variation of BCDIC alphamerics is used in most early IBM computers, including the IBM 1620, IBM 1400 series, and nonDecimal Architecture members of the IBM 700/7000 series.
The IBM 1400 series are characteraddressable machines, each location being six bits labeled B, A, 8, 4, 2 and 1, plus an odd parity check bit (C) and a word mark bit (M). For encoding digits 1 through 9, B and A are zero and the digit value represented by standard 4bit BCD in bits 8 through 1. For most other characters bits B and A are derived simply from the "12", "11", and "0" "zone punches" in the punched card character code, and bits 8 through 1 from the 1 through 9 punches. A "12 zone" punch set both B and A, an "11 zone" set B, and a "0 zone" (a 0 punch combined with any others) set A, thus the letter A, which is (12,1) in the punched card format, is encoded (B,A,1). The currency symbol $, (11,8,3) in the punched card, was encoded in memory as (B,8,2,1). This allows the circuitry to convert between the punched card format and the internal storage format to be very simple with only a few special cases. One important special case is digit 0, represented by a lone 0 punch in the card, and (8,2) in core memory.^{[17]}
The memory of the IBM 1620 is organized into 6bit addressable digits, the usual 8, 4, 2, 1 plus F, used as a flag bit and C, an odd parity check bit. BCD alphamerics are encoded using digit pairs, with the "zone" in the evenaddressed digit and the "digit" in the oddaddressed digit, the "zone" being related to the 12, 11, and 0 "zone punches" as in the 1400 series. Input/Output translation hardware converted between the internal digit pairs and the external standard 6bit BCD codes.
In the Decimal Architecture IBM 7070, IBM 7072, and IBM 7074 alphamerics are encoded using digit pairs (using twooutoffive code in the digits, not BCD) of the 10digit word, with the "zone" in the left digit and the "digit" in the right digit. Input/Output translation hardware converted between the internal digit pairs and the external standard 6bit BCD codes.
With the introduction of System/360, IBM expanded 6bit BCD alphamerics to 8bit EBCDIC, allowing the addition of many more characters (e.g., lowercase letters). A variable length Packed BCD numeric data type is also implemented, providing machine instructions that perform arithmetic directly on packed decimal data.
On the IBM 1130 and 1800, packed BCD is supported in software by IBM's Commercial Subroutine Package.
Today, BCD data is still heavily used in IBM processors and databases, such as IBM DB2, mainframes, and Power6. In these products, the BCD is usually zoned BCD (as in EBCDIC or ASCII), Packed BCD (two decimal digits per byte), or "pure" BCD encoding (one decimal digit stored as BCD in the low four bits of each byte). All of these are used within hardware registers and processing units, and in software. To convert packed decimals in EBCDIC table unloads to readable numbers, you can use the OUTREC FIELDS mask of the JCL utility DFSORT.^{[18]}
Other computers and BCD[edit]
The Digital Equipment Corporation VAX11 series includes instructions that can perform arithmetic directly on packed BCD data and convert between packed BCD data and other integer representations;^{[15]} the VAX's packed BCD format is compatible with that on IBM System/360 and IBM's later compatible processors. The MicroVAX and later VAX implementations dropped this ability from the CPU but retained code compatibility with earlier machines by implementing the missing instructions in an operating systemsupplied software library; this is invoked automatically via exception handling when the no longer implemented instructions are encountered, so that programs using them can execute without modification on the newer machines.
The Intel x86 architecture supports a unique 18digit (tenbyte) BCD format that can be loaded into and stored from the floating point registers, and computations can be performed there.^{[19]}
The Motorola 68000 series had BCD instructions.^{[20]}
In more recent computers such capabilities are almost always implemented in software rather than the CPU's instruction set, but BCD numeric data is still extremely common in commercial and financial applications. There are tricks for implementing packed BCD and zoned decimal add or subtract operations using short but difficult to understand sequences of wordparallel logic and binary arithmetic operations.^{[21]} For example, the following code (written in C) computes an unsigned 8digit packed BCD add using 32bit binary operations:
uint32_t BCDadd(uint32_t a,uint32_t b)
{
uint32_t t1, t2; // unsigned 32bit intermediate values
t1 = a + 0x06666666;
t2 = t1 ^ b; // sum without carry propagation
t1 = t1 + b; // provisional sum
t2 = t1 ^ t2; // all the binary carry bits
t2 = ~t2 & 0x11111110; // just the BCD carry bits
t2 = (t2 >> 2)  (t2 >> 3); // correction
return t1  t2; // corrected BCD sum
}
Addition with BCD[edit]
It is possible to perform addition in BCD by first adding in binary, and then converting to BCD afterwards. Conversion of the simple sum of two digits can be done by adding 6 (that is, 16 – 10) when the fivebit result of adding a pair of digits has a value greater than 9. For example:
1001 + 1000 = 10001 9 + 8 = 17
10001 is the binary, not decimal, representation of the desired result, but the mostsignificant 1 (the "carry") cannot fit in a 4bit binary number. In BCD as in decimal, there cannot exist a value greater than 9 (1001) per digit. To correct this, 6 (0110) is added to the total and then the result is treated as two nibbles:
10001 + 0110 = 00010111 => 0001 0111 17 + 6 = 23 1 7
The two nibbles of the result, 0001 and 0111, correspond to the digits "1" and "7"; this yields "17" in BCD, which is the correct result.
This technique can be extended to adding multiple digits by adding in groups from right to left, propagating the second digit as a carry, always comparing the 5bit result of each digitpair sum to 9; some CPUs provide a halfcarry flag to facilitate BCD arithmetic adjustments following binary addition and subtraction operations.
Subtraction with BCD[edit]
Subtraction is done by adding the ten's complement of the subtrahend. To represent the sign of a number in BCD, the number 0000 is used to represent a positive number, and 1001 is used to represent a negative number; the remaining 14 combinations are invalid signs. To illustrate signed BCD subtraction, consider the following problem: 357 − 432.
In signed BCD, 357 is 0000 0011 0101 0111; the ten's complement of 432 can be obtained by taking the nine's complement of 432, and then adding one. So, 999 − 432 = 567, and 567 + 1 = 568. By preceding 568 in BCD by the negative sign code, the number −432 can be represented. So, −432 in signed BCD is 1001 0101 0110 1000.
Now that both numbers are represented in signed BCD, they can be added together:
0000 0011 0101 0111 0 3 5 7 + 1001 0101 0110 1000 9 5 6 8 = 1001 1000 1011 1111 9 8 11 15
Since BCD is a form of decimal representation, several of the digit sums above are invalid. In the event that an invalid entry (any BCD digit greater than 1001) exists, 6 is added to generate a carry bit and cause the sum to become a valid entry; the reason for adding 6 is that there are 16 possible 4bit BCD values (since 2^{4} = 16), but only 10 values are valid (0000 through 1001). So adding 6 to the invalid entries results in the following:
1001 1000 1011 1111 9 8 11 15 + 0000 0000 0110 0110 0 0 6 6 = 1001 1001 0010 0101 9 9 2 5
Thus the result of the subtraction is 1001 1001 0010 0101 (−925). To confirm the result, note that the first digit is 9, which means negative; this seems to be correct, since 357 − 432 should result in a negative number. The remaining nibbles are BCD, so 1001 0010 0101 is 925; the ten's complement of 925 is 1000 − 925 = 75, so the calculated answer is −75.
If there are a different number of nibbles being added together (such as 1053 − 2), the number with the fewer digits must first be prefixed with zeros before taking the ten's complement or subtracting. So, with 1053 − 2, 2 would have to first be represented as 0002 in BCD, and the ten's complement of 0002 would have to be calculated.
Background[edit]
The binarycoded decimal scheme described in this article is the most common encoding, but there are many others; the method here can be referred to as Simple BinaryCoded Decimal (SBCD) or BCD 8421.
The following table represents decimal digits from 0 to 9 in various BCD systems.
In the headers to the table, the '8 4 2 1
', indicates the weight of each bit shown; in the fifth column, "BCD 8 4 −2 −1", two of the weights are negative. Both ASCII and EBCDIC character codes for the digits are examples of zoned BCD, and are also shown in the table.
Digit 
BCD 8 4 2 1 
Stibitz Code or Excess3  AikenCode or BCD 2 4 2 1 
BCD 8 4 −2 −1 
IBM 702, IBM 705, IBM 7080, IBM 1401 8 4 2 1  ASCII 0000 8421  EBCDIC 0000 8421 

0  0000  0011  0000  0000  1010  0011 0000  1111 0000 
1  0001  0100  0001  0111  0001  0011 0001  1111 0001 
2  0010  0101  0010  0110  0010  0011 0010  1111 0010 
3  0011  0110  0011  0101  0011  0011 0011  1111 0011 
4  0100  0111  0100  0100  0100  0011 0100  1111 0100 
5  0101  1000  1011  1011  0101  0011 0101  1111 0101 
6  0110  1001  1100  1010  0110  0011 0110  1111 0110 
7  0111  1010  1101  1001  0111  0011 0111  1111 0111 
8  1000  1011  1110  1000  1000  0011 1000  1111 1000 
9  1001  1100  1111  1111  1001  0011 1001  1111 1001 
Legal history[edit]
In the 1972 case Gottschalk v. Benson, the U.S. Supreme Court overturned a lower court decision which had allowed a patent for converting BCD encoded numbers to binary on a computer; this was an important case in determining the patentability of software and algorithms.
Comparison with pure binary[edit]
Advantages[edit]
 Many nonintegral values, such as decimal 0.2, have an infinite placevalue representation in binary (.001100110011...) but have a finite placevalue in binarycoded decimal (0.0010). Consequently, a system based on binarycoded decimal representations of decimal fractions avoids errors representing and calculating such values; this is useful in financial calculations.
 Scaling by a power of 10 is simple.
 Rounding at a decimal digit boundary is simpler. Addition and subtraction in decimal does not require rounding.
 Alignment of two decimal numbers (for example 1.3 + 27.08) is a simple, exact, shift.
 Conversion to a character form or for display (e.g., to a textbased format such as XML, or to drive signals for a sevensegment display) is a simple perdigit mapping, and can be done in linear (O(n)) time. Conversion from pure binary involves relatively complex logic that spans digits, and for large numbers no lineartime conversion algorithm is known (see Binary numeral system § Conversion to and from other numeral systems).
Disadvantages[edit]
 Some operations are more complex to implement. Adders require extra logic to cause them to wrap and generate a carry early. 15 to 20 percent more circuitry is needed for BCD add compared to pure binary.^{[citation needed]} Multiplication requires the use of algorithms that are somewhat more complex than shiftmaskadd (a binary multiplication, requiring binary shifts and adds or the equivalent, perdigit or group of digits is required)
 Standard BCD requires four bits per digit, roughly 20 percent more space than a binary encoding (the ratio of 4 bits to log_{2}10 bits is 1.204). When packed so that three digits are encoded in ten bits, the storage overhead is greatly reduced, at the expense of an encoding that is unaligned with the 8bit byte boundaries common on existing hardware, resulting in slower implementations on these systems.
 Practical existing implementations of BCD are typically slower than operations on binary representations, especially on embedded systems,^{[citation needed]} due to limited processor support for native BCD operations.
Application[edit]
The BIOS in many personal computers stores the date and time in BCD because the MC6818 realtime clock chip used in the original IBM PC AT motherboard provided the time encoded in BCD; this form is easily converted into ASCII for display.^{[22]}
The Atari 8bit family of computers used BCD to implement floatingpoint algorithms; the MOS 6502 processor has a BCD mode that affects the addition and subtraction instructions. The Psion Organiser 1 handheld computer’s manufacturersupplied software also used entirely BCD to implement floating point; later Psion models used binary exclusively.
Early models of the PlayStation 3 store the date and time in BCD; this led to a worldwide outage of the console on 1 March 2010. The last two digits of the year stored as BCD were misinterpreted as 16 causing an error in the unit's date, rendering most functions inoperable; this has been referred to as the Year 2010 Problem.
Representational variations[edit]
Various BCD implementations exist that employ other representations for numbers. Programmable calculators manufactured by Texas Instruments, HewlettPackard, and others typically employ a floatingpoint BCD format, typically with two or three digits for the (decimal) exponent; the extra bits of the sign digit may be used to indicate special numeric values, such as infinity, underflow/overflow, and error (a blinking display).
Signed variations[edit]
Signed decimal values may be represented in several ways; the COBOL programming language, for example, supports a total of five zoned decimal formats, each one encoding the numeric sign in a different way:
Type  Description  Example 

Unsigned  No sign nibble  F1 F2 F3

Signed trailing (canonical format)  Sign nibble in the last (least significant) byte  F1 F2 C3

Signed leading (overpunch)  Sign nibble in the first (most significant) byte  C1 F2 F3

Signed trailing separate  Separate sign character byte ('+' or '−' ) following the digit bytes

F1 F2 F3 2B

Signed leading separate  Separate sign character byte ('+' or '−' ) preceding the digit bytes

2B F1 F2 F3

Telephony Binary Coded Decimal (TBCD)[edit]
3GPP developed TBCD,^{[23]} an expansion to BCD where the remaining (unused) bit combinations are used to add specific telephony characters,^{[24]}^{[25]} with digits similar to those found in telephone keypads original design.
Decimal Digit 
TBCD 8 4 2 1 

*  1 0 1 0 
#  1 0 1 1 
a  1 1 0 0 
b  1 1 0 1 
c  1 1 1 0 
Used as filler when there is an odd number of digits  1 1 1 1 
The mentioned 3GPP document defines TBCDSTRING with swapped nibbles in each byte. Bits, octets and digits indexed from 1, bits from the right, digits and octets from the left.
bits 8765 of octet n encoding digit 2n
bits 4321 of octet n encoding digit 2(n1) +1
Meaning number 1234
, would become 21 43
in TBCD.
Alternative encodings[edit]
If errors in representation and computation are more important than the speed of conversion to and from display, a scaled binary representation may be used, which stores a decimal number as a binaryencoded integer and a binaryencoded signed decimal exponent. For example, 0.2 can be represented as 2×10^{−1}.
This representation allows rapid multiplication and division, but may require shifting by a power of 10 during addition and subtraction to align the decimal points, it is appropriate for applications with a fixed number of decimal places that do not then require this adjustment—particularly financial applications where 2 or 4 digits after the decimal point are usually enough. Indeed, this is almost a form of fixed point arithmetic since the position of the radix point is implied.
Chen–Ho encoding provides a boolean transformation for converting groups of three BCDencoded digits to and from 10bit values that can be efficiently encoded in hardware with only 2 or 3 gate delays. Densely packed decimal (DPD) is a similar scheme that is used for most of the significand, except the lead digit, for one of the two alternative decimal encodings specified in the IEEE 7542008 standard.
See also[edit]
 Biquinary coded decimal
 Binary integer decimal (BID)
 Chen–Ho encoding
 Densely packed decimal (DPD)
 Double dabble, an algorithm for converting binary numbers to BCD
 Gray code
 Year 2000 problem
 Decimal computer
 Binarycoded ternary (BCT)
Notes[edit]
References[edit]
 ^ Intel. "ia32 architecture manual" (PDF). Intel. Retrieved 20150701.
 ^ Schneider, HansJochen (1986). Lexikon der Informatik und Datenverarbeitung (in German) (2 ed.). R. Oldenbourg Verlag München Wien. ISBN 3486226622.
 ^ Tafel, Hans Jörg (1971). Written at RWTH, Aachen, Germany. Einführung in die digitale Datenverarbeitung [Introduction to digital information processing] (in German). Munich, Germany: Carl Hanser Verlag. ISBN 3446105697.
 ^ Steinbuch, Karl W.; Weber, Wolfgang; Heinemann, Traute, eds. (1974) [1967]. Taschenbuch der Informatik  Band II  Struktur und Programmierung von EDVSystemen. Taschenbuch der Nachrichtenverarbeitung (in German). 2 (3 ed.). Berlin, Germany: SpringerVerlag. ISBN 3540062416. LCCN 7380607.
 ^ Tietze, Ulrich; Schenk, Christoph (20121206). Advanced Electronic Circuits. Springer Science & Business Media. ISBN 9783642812415. 9783642812415. Retrieved 20150805.
 ^ Kowalski, Emil (20130308) [1970]. Nuclear Electronics. SpringerVerlag. doi:10.1007/9783642876639. ISBN 9783642876639. 9783642876639, 9783642876646. Retrieved 20150805.
 ^ Ferretti, Vittorio (20130313). Wörterbuch der Elektronik, Datentechnik und Telekommunikation / Dictionary of Electronics, Computing and Telecommunications: Teil 1: DeutschEnglisch / Part 1: GermanEnglish. 1 (2 ed.). SpringerVerlag. ISBN 9783642980886. 9783642980886. Retrieved 20150805.
 ^ Speiser, Ambrosius Paul (1965) [1961]. Digitale Rechenanlagen  Grundlagen / Schaltungstechnik / Arbeitsweise / Betriebssicherheit [Digital computers  Basics / Circuits / Operation / Reliability] (in German) (2 ed.). ETH Zürich, Zürich, Switzerland: SpringerVerlag / IBM. p. 209. LCCN 6514624. 0978.
 ^ Cowlishaw, Mike F. (2015) [1981,2008]. "General Decimal Arithmetic". Retrieved 20160102.
 ^ Parag K., Lala (2007). Principles of Modern Digital Design. John Wiley & Sons. pp. 20–25. ISBN 9780470072967.
 ^ University of Alicante. "A Cordicbased Architecture for High Performance Decimal Calculations" (PDF). IEEE. Retrieved 20150815.
 ^ "Decimal CORDIC Rotation based on Selection by Rounding: Algorithm and Architecture" (PDF). British Computer Society. Retrieved 20150814.
 ^ "Chapter 8: Decimal Instructions", IBM System/370 Principles of Operation, IBM, March 1980
 ^ "Chapter 3: Data Representation", PDP11 Architecture Handbook, Digital Equipment Corporation, 1983
 ^ ^{a} ^{b} VAX11 Architecture Handbook, Digital Equipment Corporation, 1985
 ^ "ILE RPG Reference".
 ^ IBM BM 1401/1440/1460/1410/7010 Character Code Chart in BCD Order^{[permanent dead link]}
 ^ http://publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.iceg200%2Fenf.htm^{[permanent dead link]}
 ^ Intel® 64 and IA32 Architectures Software Developer's Manual, Volume 1: Basic Architecture. Intel Corporation. December 2016. pp. 4–9.
 ^ url=http://www.tigernt.com/onlineDoc/68000.pdf
 ^ Jones, Douglas W. (20151125) [1999]. "BCD Arithmetic, a tutorial". Arithmetic Tutorials. Iowa City, Iowa, USA: The University of Iowa, Department of Computer Science. Retrieved 20160103.
 ^ http://www.se.ecu.edu.au/units/ens1242/lectures/ens_Notes_08.pdf^{[permanent dead link]}
 ^ 3GPP TS 29.002: Mobile Application Part (MAP) specification (Technical report). 2013. sec. 17.7.8 Common data types.
 ^ "Signalling Protocols and Switching (SPS) Guidelines for using Abstract Syntax Notation One (ASN.1) in telecommunication application protocols" (PDF). p. 15.
 ^ "XOM Mobile Application Part (XMAP) Specification" (PDF). p. 93.
Further reading[edit]
 Mackenzie, Charles E. (1980). Coded Character Sets, History and Development. The Systems Programming Series (1 ed.). AddisonWesley Publishing Company, Inc. p. xii. ISBN 0201144603. LCCN 7790165. Retrieved 20160522. [1]
 Richards, Richard Kohler (1955). Arithmetic Operations in Digital Computers. New York, USA: van Nostrand. pp. 397–.
 Schmid, Hermann (1974). Decimal Computation (1 ed.). Binghamton, New York, USA: John Wiley & Sons. ISBN 047176180X. and Schmid, Hermann (1983) [1974]. Decimal Computation (1 (reprint) ed.). Malabar, Florida, USA: Robert E. Krieger Publishing Company. ISBN 0898743184. (NB. At least some batches of the Krieger reprint edition were misprints with defective pages 115–146.)
 Massalin, Henry (October 1987). Katz, Randy (ed.). "Superoptimizer: A Look at the Smallest Program" (PDF). Proceedings of the Second International Conference on Architectural Support for Programming Languages and Operating Systems ACM SIGOPS Operating Systems Review. 21 (4): 122–126. doi:10.1145/36206.36194 (inactive 20190722). ISBN 0818608056. Archived (PDF) from the original on 20170704. Retrieved 20120425. Lay summary (19950614). (Also: ACM SIGPLAN Notices, Vol. 22 #10, IEEE Computer Society Press #87CH24406, October 1987)
 VLSI designs for redundant binarycoded decimal addition, Behrooz Shirazi, David Y. Y. Yun, and Chang N. Zhang, IEEE Seventh Annual International Phoenix Conference on Computers and Communications, 1988, pp52–56, IEEE, March 1988
 Fundamentals of Digital Logic by Brown and Vranesic, 2003
 Modified Carry Look Ahead BCD Adder With CMOS and Reversible Logic Implementation, Himanshu Thapliyal and Hamid R. Arabnia, Proceedings of the 2006 International Conference on Computer Design (CDES'06), ISBN 1601320094, pp64–69, CSREA Press, November 2006
 Reversible Implementation of DenselyPackedDecimal Converter to and from BinaryCodedDecimal Format Using in IEEE754R, A. Kaivani, A. Zaker Alhosseini, S. Gorgin, and M. Fazlali, 9th International Conference on Information Technology (ICIT'06), pp273–276, IEEE, December 2006.
 Cowlishaw, Mike F. (2009) [2002,2008]. "Bibliography of material on Decimal Arithmetic – by category". General Decimal Arithmetic. IBM. Retrieved 20160102.
External links[edit]
 Cowlishaw, Mike F. (2014) [2000]. "A Summary of ChenHo Decimal Data encoding". General Decimal Arithmetic. IBM. Retrieved 20160102.
 Cowlishaw, Mike F. (2007) [2000]. "A Summary of Densely Packed Decimal encoding". General Decimal Arithmetic. IBM. Retrieved 20160102.
 Convert BCD to decimal, binary and hexadecimal and vice versa
 BCD for Java