SUPPORT THE WORK

GetWiki

Binary-coded decimal

ARTICLE SUBJECTS
aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
ARTICLE TYPES
essay  →
feed  →
help  →
system  →
wiki  →
ARTICLE ORIGINS
critical  →
discussion  →
forked  →
imported  →
original  →
Binary-coded decimal
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{Short description|System of digitally encoding numbers}}{{redir|BCD code|BCD character sets|BCD (character encoding)||}}{{Use dmy dates|date=May 2019|cs1-dates=y}}{{Use list-defined references|date=January 2022}}{{anchor|Compressed}}File:Binary clock.svg|250px|thumbnail|right|A binary clock might use LEDs to express binary values. In this clock, each column of LEDs shows a binary-coded decimal numeral of the traditional sexagesimalsexagesimalIn computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used for a sign or other indications (e.g. error or overflow).In byte-oriented systems (i.e. most modern computers), the term unpacked BCD usually implies a full byte for each digit (often including a sign), whereas packed BCD typically encodes two 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 four-bit encoding, however, may vary for technical reasons (e.g. Excess-3).{{anchor|Pseudo-tetrade}}The ten states representing a BCD digit are sometimes called tetrades (the nibble typically needed to hold them is also known as a tetrade) while the unused, don't care-states are named {{Interlanguage link multi|pseudo-tetrade|de|3=Pseudotetrade|lt=pseudo-tetrad(e)s}}, pseudo-decimals or pseudo-decimal digits.BCD's main virtue, in comparison to binary positional systems, is its more accurate representation and rounding of decimal quantities, as well as its ease of conversion into conventional human-readable representations. Its principal drawbacks are a slight increase in the complexity of the circuits needed to implement basic arithmetic as well as 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 68000-series processors. BCD per se is not as widely used as in the past, and is unavailable or limited in newer instruction sets (e.g., ARM; x86 in long mode). However, decimal fixed-point and decimal floating-point formats are still important and continue to be used in financial, commercial, and industrial computing, where the subtle conversion and fractional rounding errors that are inherent in binary floating point formats cannot be tolerated.

{{anchor|Unpacked BCD|NBCD|8421|8-4-2-1}}Background

BCD takes advantage of the fact that any one decimal numeral can be represented by a four-bit pattern. An obvious way of encoding digits is Natural BCD (NBCD), where each decimal digit is represented by its corresponding four-bit binary value, as shown in the following table. This is also called "8421" encoding.{| class="wikitable" style="text-align:center;"! scope="col" rowspan="2" | Decimal digit! scope="col" colspan="4" | BCD
! 8 !! 4 !! 2 !! 1
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 1
This scheme can also be referred to as Simple Binary-Coded Decimal (SBCD) or BCD 8421, and is the most common encoding. Others include the so-called "4221" and "7421" encoding – named after the weighting used for the bits – and "Excess-3". For example, the BCD digit 6, {{code|0110'b}} in 8421 notation, is {{code|1100'b}} in 4221 (two encodings are possible), {{code|0110'b}} in 7421, while in Excess-3 it is {{code|1001'b}} (6 + 3 = 9).{| class="wikitable" style="text-align:center;"|+ 4-bit BCD codes and pseudo-tetrades! Bit !! Weight !! style="background:lightgray"| 0 !! style="background:lightgray"| 1 !! style="background:lightgray"| 2 !! style="background:lightgray"| 3 !! style="background:lightgray"| 4 !! style="background:lightgray"| 5 !! style="background:lightgray"| 6 !! style="background:lightgray"| 7 !! style="background:lightgray"| 8 !! style="background:lightgray"| 9 !! style="background:lightgray"|10 !! style="background:lightgray"|11 !! style="background:lightgray"|12 !! style="background:lightgray"|13 !! style="background:lightgray"|14 !! style="background:lightgray"|15 !!         Comment        
8 0 0 0 0 0 0 0 0 style="background:#0FF"1 style="background:#0FF"1 style="background:#0FF"1 style="background:#0FF"1 rowspan="4"|Binary
4 0 0 0 0 style="background:#0FF"1 style="background:#0FF"1 0 0 0 0 style="background:#0FF"1 style="background:#0FF"1
2 0 0 style="background:#0FF"1 0 0 style="background:#0FF"1 0 0 style="background:#0FF"1 0 0 style="background:#0FF"1
1 0 style="background:#0FF"1 0 style="background:#0FF"1 0 style="background:#0FF"1 0 style="background:#0FF"1
Name style="background:lightgray"1 style="background:lightgray"3 style="background:lightgray"5 style="background:lightgray"7 style="background:lightgray"9 style="background:lightgray"11 style="background:lightgray"13 style="background:lightgray"15 Decimal
8 4 2 1 (XS-0) style="background:#0FF"1 style="background:#0FF"3 style="background:#0FF"5 style="background:#0FF"7 style="background:#0FF"9 style="background:gray"11 style="background:gray"13 style="background:gray"15
7421}}colspan="2"7 4 2 1 >0 style="background:#0FF"2 style="background:#0FF"4 style="background:#0FF"6 style="background:gray"7 style="background:#0FF"9 style="background:gray"  style="background:gray"  style="background:gray"|
'''{{nowrapAiken code>Aiken (2 4 2 1)}}''' style="background:#0FF"1 style="background:#0FF"3 style="background:#0FF"  style="background:gray"  style="background:gray"  style="background:gray"5 style="background:#0FF"7 style="background:#0FF"9
'''{{nowrapExcess-3 code>Excess-3 (XS-3)}}''' style="background:gray"-2 style="background:gray"0 style="background:#0FF"2 style="background:#0FF"4 style="background:#0FF"6 style="background:#0FF"8 style="background:#0FF"10 style="background:gray"12
'''{{nowrapExcess-6 code>Excess-6 (XS-6)}}''' style="background:gray"-5 style="background:gray"-3 style="background:gray"-1 style="background:#0FF"1 style="background:#0FF"3 style="background:#0FF"5 style="background:#0FF"7 style="background:#0FF"9
Jump-at-2}}colspan="2"Jump-at-2 (2 4 2 1) >0 style="background:#0FF"  style="background:gray"  style="background:gray"  style="background:gray"2 style="background:#0FF"4 style="background:#0FF"6 style="background:#0FF"8 style="background:#0FF"|
Jump-at-2}}colspan="2"Jump-at-8 (2 4 2 1)}} style="background:#0FF"1 style="background:#0FF"3 style="background:#0FF"5 style="background:#0FF"7 style="background:gray"  style="background:gray"  style="background:gray"  style="background:#0FF"9
4221}}colspan="2"4 2 2 1 (I)}} style="background:#0FF"1 style="background:#0FF"3 style="background:gray"  style="background:#0FF"5 style="background:gray"  style="background:gray"  style="background:#0FF"7 style="background:#0FF"9
4221 II}}colspan="2"4 2 2 1 (II)}} style="background:#0FF"1 style="background:#0FF"3 style="background:gray"  style="background:#0FF"5 style="background:gray"  style="background:#0FF"7 style="background:gray"  style="background:#0FF"9
5421}}colspan="2"5 4 2 1 >0 style="background:#0FF"2 style="background:#0FF"4 style="background:gray"  style="background:gray"5 style="background:#0FF"7 style="background:#0FF"9 style="background:gray"  style="background:gray"|
5221}}colspan="2"5 2 2 1 >0 style="background:#0FF"2 style="background:#0FF"  style="background:gray"4 style="background:gray"5 style="background:#0FF"7 style="background:#0FF"  style="background:gray"9 style="background:gray"|
5121}}colspan="2"5 1 2 1 >0 style="background:#0FF"2 style="background:#0FF"  style="background:gray"  style="background:#0FF"5 style="background:#0FF"7 style="background:#0FF"  style="background:gray"  style="background:#0FF"|
5311}}colspan="2"5 3 1 1 >0 style="background:#0FF"  style="background:#0FF"3 style="background:#0FF"  style="background:gray"5 style="background:#0FF"  style="background:#0FF"8 style="background:#0FF"  style="background:gray"|
White}}colspan="2"{{nowrap>White (5 2 1 1)}} style="background:#0FF"1 style="background:gray"2 style="background:gray"3 style="background:gray"4 style="background:#0FF"6 style="background:gray"7 style="background:gray"8 style="background:gray"9
5211}}colspan="2"5 2 1 1 >0 style="background:#0FF"  style="background:#0FF"  style="background:#0FF"  style="background:#0FF"5 style="background:gray"6 style="background:gray"7 style="background:gray"8 style="background:#0FF"|
  style="background:lightgray"1 style="background:lightgray"3 style="background:lightgray"5 style="background:lightgray"7 style="background:lightgray"9 style="background:lightgray"11 style="background:lightgray"13 style="background:lightgray"15
Tape}}colspan="2"Magnetic tape >  style="background:#0FF"2 style="background:#0FF"4 style="background:#0FF"6 style="background:#0FF"8 style="background:#0FF"0 style="background:gray"  style="background:gray"  style="background:gray"|
Paul}}colspan="2"Paul >  style="background:#0FF"3 style="background:#0FF"6 style="background:#0FF"5 style="background:#0FF"  style="background:#0FF"  style="background:gray"8 style="background:#0FF"  style="background:gray"|
'''{{nowrapGray BCD code>Gray}}''' style="background:#0FF"1 style="background:#0FF"2 style="background:#0FF"7 style="background:#0FF" 4 style="background:gray" 14 style="background:gray"13 style="background:#0FF"9 style="background:gray"10
'''{{nowrapGlixon code>Glixon}}''' style="background:#0FF"1 style="background:#0FF"2 style="background:#0FF"7 style="background:#0FF"4 style="background:#0FF"  style="background:gray"  style="background:#0FF"  style="background:gray" 
Ledley}}colspan="2"Ledley >0 style="background:#0FF"7 style="background:#0FF"4 style="background:#0FF"  style="background:gray"  style="background:gray"8 style="background:gray"9 style="background:gray"|
4311}}colspan="2"4 3 1 1 >0 style="background:#0FF"  style="background:#0FF"3 style="background:gray"  style="background:#0FF"4 style="background:gray"  style="background:#0FF"7 style="background:gray"8 style="background:#0FF"|
LARC}}colspan="2"UNIVAC LARC>LARC style="background:#0FF"1 style="background:gray"2 style="background:gray"  style="background:#0FF"3 style="background:#0FF"6 style="background:gray"7 style="background:gray"  style="background:#0FF"8
Klar}}colspan="2"Klar >0 style="background:#0FF"  style="background:#0FF"  style="background:gray"4 style="background:#0FF"9 style="background:#0FF"  style="background:#0FF"  style="background:gray"5 style="background:#0FF"|
'''{{nowrapPetherick code>Petherick (RAE)}}''' style="background:gray"1 style="background:#0FF"2 style="background:gray"0 style="background:#0FF"  style="background:gray"8 style="background:#0FF"7 style="background:gray"9 style="background:#0FF" 
'''{{nowrapO'Brien code I>O'Brien I (Watts)}}''' style="background:#0FF"1 style="background:#0FF"2 style="background:gray"  style="background:#0FF"  style="background:#0FF"8 style="background:#0FF"7 style="background:gray"  style="background:#0FF" 
5-cyclic}}colspan="2"5-cyclic >0 style="background:#0FF"  style="background:gray"4 style="background:gray"5 style="background:#0FF"8 style="background:#0FF"  style="background:gray"9 style="background:gray"|
'''{{nowrapTompkins code I>Tompkins I}}''' style="background:#0FF"1 style="background:#0FF"2 style="background:gray"  style="background:#0FF"  style="background:gray"9 style="background:gray"  style="background:#0FF"7 style="background:#0FF"6
Lippel}}colspan="2"Lippel >0 style="background:#0FF"2 style="background:#0FF"  style="background:gray"4 style="background:gray"  style="background:#0FF"  style="background:gray"8 style="background:#0FF"6 style="background:#0FF"|
'''{{nowrapO'Brien code II>O'Brien II}}''' style="background:gray"0 style="background:#0FF"1 style="background:#0FF"  style="background:#0FF"  style="background:gray"9 style="background:#0FF"8 style="background:#0FF"  style="background:#0FF" 
'''{{nowrapTompkins code II>Tompkins II}}''' style="background:gray"  style="background:#0FF"1 style="background:#0FF"3 style="background:gray"2 style="background:gray"7 style="background:#0FF"8 style="background:#0FF"6 style="background:gray" 
'''{{nowrapExcess-3 Gray code>Excess-3 Gray}}''' style="background:gray"-2 style="background:#0FF"-1 style="background:#0FF"3 style="background:#0FF"2 style="background:gray"11 style="background:#0FF"10 style="background:#0FF"6 style="background:#0FF"7
63−2−1}}colspan="2"6 3 −2 −1 (I) >  style="background:gray"  style="background:gray"3 style="background:#0FF"1 style="background:#0FF"  style="background:#0FF"4 style="background:#0FF"9 style="background:gray"7 style="background:#0FF"|
63−2−1 II}}colspan="2"6 3 −2 −1 (II) >0 style="background:gray"  style="background:gray"3 style="background:#0FF"1 style="background:gray"6 style="background:#0FF"4 style="background:gray"9 style="background:#0FF"7 style="background:gray"|
84−2−1}}colspan="2"8 4 −2 −1 >0 style="background:gray"  style="background:gray"4 style="background:#0FF"2 style="background:#0FF"8 style="background:#0FF"6 style="background:#0FF"  style="background:gray"  style="background:#0FF"|
Lucal}}colspan="2"Lucal code>Lucal style="background:#0FF"15 style="background:gray"1 style="background:gray"3 style="background:#0FF"13 style="background:#0FF"7 style="background:#0FF"9 style="background:#0FF"11 style="background:gray"5
Kautz}}colspan="2"Kautz I >0 style="background:gray"  style="background:#0FF"  style="background:#0FF"1 style="background:#0FF"  style="background:#0FF"9 style="background:gray"8 style="background:#0FF"  style="background:#0FF"|
Kautz II}}colspan="2"Kautz II >  style="background:#0FF"4 style="background:gray"1 style="background:gray"3 style="background:#0FF"8 style="background:gray"6 style="background:#0FF"  style="background:#0FF"5 style="background:gray"|
Susskind}}colspan="2"Susskind I >  style="background:#0FF"  style="background:#0FF"  style="background:#0FF"3 style="background:#0FF"  style="background:#0FF"  style="background:#0FF"5 style="background:gray"6 style="background:#0FF"|
Susskind II}}colspan="2"Susskind II >  style="background:#0FF"  style="background:#0FF"  style="background:#0FF"  style="background:#0FF"4 style="background:gray"3 style="background:#0FF"5 style="background:gray"6 style="background:#0FF"|
  style="background:lightgray"1 style="background:lightgray"3 style="background:lightgray"5 style="background:lightgray"7 style="background:lightgray"9 style="background:lightgray"11 style="background:lightgray"13 style="background:lightgray"15
The following table represents decimal digits from 0 to 9 in various BCD encoding systems. In the headers, the "8{{thinsp}}4{{thinsp}}2{{thinsp}}1" indicates the weight of each bit. In the fifth column ("BCD 8{{thinsp}}4{{thinsp}}−2{{thinsp}}−1"), two of the weights are negative. Both ASCII and EBCDIC character codes for the digits, which are examples of zoned BCD, are also shown.{| border="1" cellpadding="2" cellspacing="0" style="margin:auto;"! style="background:#e0e0e0;"|  Digit! style="background:#e0e0e0;"| BCD8{{thinsp}}4{{thinsp}}2{{thinsp}}1! style="background:#e0e0e0;"| Stibitz code or Excess-3! style="background:#e0e0e0;"| Aiken-Code or BCD2{{thinsp}}4{{thinsp}}2{{thinsp}}1! style="background:#e0e0e0;"| BCD8{{thinsp}}4{{thinsp}}−2{{thinsp}}−1! style="background:#e0e0e0;"| {{nowrap| IBM 702, }} {{nowrap| IBM 705, }} {{nowrap| IBM 7080, }} {{nowrap| IBM 1401 }} 8{{thinsp}}4{{thinsp}}2{{thinsp}}1! style="background:#e0e0e0;"| ASCII 0000 8421! style="background:#e0e0e0;"| EBCDIC 0000 8421
style="text-align:center;"! style="background:#f0f0f0;"|0| 0000| 0011| 0000| 0000| 1010| 0011 0000| 1111 0000
style="text-align:center;"! style="background:#f0f0f0;"|1| 0001| 0100| 0001| 0111| 0001| 0011 0001| 1111 0001
style="text-align:center;"! style="background:#f0f0f0;"|2| 0010| 0101| 0010| 0110| 0010| 0011 0010| 1111 0010
style="text-align:center;"! style="background:#f0f0f0;"|3| 0011| 0110| 0011| 0101| 0011| 0011 0011| 1111 0011
style="text-align:center;"! style="background:#f0f0f0;"|4| 0100| 0111| 0100| 0100| 0100| 0011 0100| 1111 0100
style="text-align:center;"! style="background:#f0f0f0;"|5| 0101| 1000| 1011| 1011| 0101| 0011 0101| 1111 0101
style="text-align:center;"! style="background:#f0f0f0;"|6| 0110| 1001| 1100| 1010| 0110| 0011 0110| 1111 0110
style="text-align:center;"! style="background:#f0f0f0;"|7| 0111| 1010| 1101| 1001| 0111| 0011 0111| 1111 0111
style="text-align:center;"! style="background:#f0f0f0;"|8| 1000| 1011| 1110| 1000| 1000| 0011 1000| 1111 1000
style="text-align:center;"! style="background:#f0f0f0;"|9| 1001| 1100| 1111| 1111| 1001| 0011 1001| 1111 1001
As most computers deal with data in 8-bit bytes, it is possible to use one of the following methods to encode a BCD number:
  • Unpacked: Each decimal digit is encoded into one byte, with four bits representing the number and the remaining bits having no significance.
  • Packed: Two decimal digits are encoded into a single byte, with one digit 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 byte is zero through ninety-nine 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 big-endian 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.

Packed BCD

In packed BCD (or packed decimal), each nibble represents 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 4-byte value consists of 8 nibbles, wherein the upper 7 nibbles store the digits of a 7-digit 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 ASCII-8 standard that never passed. Most implementations also provide unsigned BCD values with a sign nibble of 1111 (F). ILE RPG uses 1111 (F) for positive and 1101 (D) for negative. 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)).{| class="wikitable" style="margin:auto; width:40%;"! style="background:#e0e0e0; width:20%;"|Signdigit! style="background:#e0e0e0; width:20%;"|BCD8 4 2 1! style="background:#e0e0e0; width:20%;"|Sign! style="background:#e0e0e0; width:40%;"|Notes
style="text-align:center;"! style="background:#f0f0f0;"|A| 1 0 1 0| +|  
style="text-align:center;"! style="background:#f0f0f0;"|B| 1 0 1 1| −|  
style="text-align:center;"! style="background:#f0f0f0;"|C| 1 1 0 0| +| Preferred
style="text-align:center;"! style="background:#f0f0f0;"|D| 1 1 0 1| −| Preferred
style="text-align:center;"! style="background:#f0f0f0;"|E| 1 1 1 0| +|  
style="text-align:center;"! style="background:#f0f0f0;"|F| 1 1 1 1| +| Unsigned
No matter how many bytes wide a word is, there is 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 {{sfrac|1|2}}(d+1) bytes of storage space.For example, a 4-byte (32-bit) 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{{snd}} that with the most significant two digits{{snd}} is usually stored in the lowest address in memory, independent of the endianness of the machine.In contrast, a 4-byte 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 (using about 20% more memory than binary notation to store the same numbers), conversion to ASCII, EBCDIC, or the various encodings of Unicode is made 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 fixed-point 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 "COMPUTATIONAL-3" (an IBM extension adopted by many other compiler vendors) or "PACKED-DECIMAL" (part of the 1985 COBOL standard) data type. It is supported in PL/I as "FIXED DECIMAL". Beside 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 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 32-bit 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.)

Fixed-point packed decimal

Fixed-point decimal numbers are supported by some programming languages (such as COBOL and PL/I). 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 fixed-point value +1,234.567 when the implied decimal point is located between the fourth and fifth 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.

Higher-density encodings

If a decimal digit requires four bits, then three decimal digits require 12 bits. However, since 210 (1,024) is greater than 103 (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.

{{anchor|Zoned BCD}}Zoned decimal

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

{| style="margin:auto; width:70%;" class="wikitable"! style="background:#e0e0e0;"|BCD digit! style="background:#e0e0e0;" colspan="4"|Hexadecimal! style="background:#e0e0e0;" colspan="4"|EBCDIC character
style="text-align:center; font-family: monospace; font-size: larger"
0+C0A0E0F0{ (*)  (*)0
style="text-align:center; font-family: monospace; font-size: larger"
1+C1A1E1F1A~ (*) 1
style="text-align:center; font-family: monospace; font-size: larger"
2+C2A2E2F2BsS2
style="text-align:center; font-family: monospace; font-size: larger"
3+C3A3E3F3CtT3
style="text-align:center; font-family: monospace; font-size: larger"
4+C4A4E4F4DuU4
style="text-align:center; font-family: monospace; font-size: larger"
5+C5A5E5F5EvV5
style="text-align:center; font-family: monospace; font-size: larger"
6+C6A6E6F6FwW6
style="text-align:center; font-family: monospace; font-size: larger"
7+C7A7E7F7GxX7
style="text-align:center; font-family: monospace; font-size: larger"
8+C8A8E8F8HyY8
style="text-align:center; font-family: monospace; font-size: larger"
9+C9A9E9F9IzZ9
style="text-align:center; font-family: monospace; font-size: larger"
0−D0B0  }  (*)^  (*)  
style="text-align:center; font-family: monospace; font-size: larger"
1−D1B1  J   
style="text-align:center; font-family: monospace; font-size: larger"
2−D2B2  K   
style="text-align:center; font-family: monospace; font-size: larger"
3−D3B3  L   
style="text-align:center; font-family: monospace; font-size: larger"
4−D4B4  M   
style="text-align:center; font-family: monospace; font-size: larger"
5−D5B5  N   
style="text-align:center; font-family: monospace; font-size: larger"
6−D6B6  O   
style="text-align:center; font-family: monospace; font-size: larger"
7−D7B7  P   
style="text-align:center; font-family: monospace; font-size: larger"
8−D8B8  Q   
style="text-align:center; font-family: monospace; font-size: larger"
9−D9B9  R   
(*) Note: These characters vary depending on the local character code page setting.

Fixed-point zoned decimal

Some languages (such as COBOL and PL/I) directly support fixed-point zoned decimal values, assigning an implicit decimal point at some location between the decimal digits of a number.For example, given a six-byte 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

Operations with BCD

Addition

It is possible to perform addition 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 five-bit result of adding a pair of digits has a value greater than 9. The reason for adding 6 is that there are 16 possible 4-bit BCD values (since 24 = 16), but only 10 values are valid (0000 through 1001). For example:
1001 + 1000 = 10001
9 + 8 = 17
10001 is the binary, not decimal, representation of the desired result, but the most significant 1 (the "carry") cannot fit in a 4-bit 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 5-bit result of each digit-pair sum to 9. Some CPUs provide a half-carry flag to facilitate BCD arithmetic adjustments following binary addition and subtraction operations. The Intel 8080, the Zilog Z80 and the CPUs of the x86 family provide the opcode DAA (Decimal Adjust Accumulator).

Subtraction

Subtraction is done by adding the ten's complement of the subtrahend to the minuend. 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. 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.

BCD in computers

IBM

IBM used the terms Binary-Coded Decimal Interchange Code (BCDIC, sometimes just called BCD), for 6-bit alphanumeric codes that represented numbers, upper-case letters and special characters. Some variation of BCDIC alphamerics is used in most early IBM computers, including the IBM 1620 (introduced in 1959), IBM 1400 series, and non-decimal architecture members of the IBM 700/7000 series.The IBM 1400 series are character-addressable 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 4-bit 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.The memory of the IBM 1620 is organized into 6-bit 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 even-addressed digit and the "digit" in the odd-addressed 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 6-bit BCD codes.In the decimal architecture IBM 7070, IBM 7072, and IBM 7074 alphamerics are encoded using digit pairs (using two-out-of-five code in the digits, not BCD) of the 10-digit 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 6-bit BCD codes.With the introduction of System/360, IBM expanded 6-bit BCD alphamerics to 8-bit 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 databases such as IBM Db2 and processors such as z/Architecture and POWER6 and later Power ISA processors. 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.

Other computers

The Digital Equipment Corporation VAX series includes instructions that can perform arithmetic directly on packed BCD data and convert between packed BCD data and other integer representations. 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 system-supplied software library. This is invoked automatically via exception handling when the defunct instructions are encountered, so that programs using them can execute without modification on the newer machines.The Intel x86 architecture supports a unique 18-digit (ten-byte) BCD format that can be loaded into and stored from the floating point registers, from where computations can be performed.The Motorola 68000 series had BCD instructions.In more recent computers such capabilities are almost always implemented in software rather than the CPU's instruction set, but BCD numeric data are 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 word-parallel logic and binary arithmetic operations. For example, the following code (written in C) computes an unsigned 8-digit packed BCD addition using 32-bit binary operations:uint32_t BCDadd(uint32_t a, uint32_t b){
uint32_t t1, t2; // unsigned 32-bit 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
}

BCD in electronics

{{Multiple issues|section=true|{{More citations needed section|date=January 2018}}{{Primary sources|section|date=January 2018}}}}BCD is 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 sub-circuit. This matches much more closely the physical reality of display hardware—a designer might choose to use a series of separate identical seven-segment displays to build a metering circuit, for example. If the numeric quantity were stored and manipulated as pure binary, interfacing with such a display would require complex circuitry. Therefore, in cases where the calculations are relatively simple, working throughout with BCD can lead to an overall simpler 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, representing numbers internally in BCD format results in smaller code, since a conversion from or to binary representation can be expensive on such limited processors. For these applications, some small processors feature dedicated arithmetic modes, which assist when writing routines that manipulate BCD quantities.

Comparison with pure binary

Advantages

  • Scaling by a power of 10 is simple.
  • Rounding at a decimal digit boundary is simpler. Addition and subtraction in decimal do not require rounding.{{dubious|Rounding|date=November 2021}}
  • The 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 text-based format such as XML, or to drive signals for a seven-segment display) is a simple per-digit 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 linear-time conversion algorithm is known (see {{see section|Binary numeral system|Conversion to and from other numeral systems}}).
  • Many non-integral values, such as decimal 0.2, have an infinite place-value representation in binary (.001100110011...) but have a finite place-value in binary-coded decimal (0.0010). Consequently, a system based on binary-coded decimal representations of decimal fractions avoids errors representing and calculating such values. This is useful in financial calculations.

Disadvantages

  • Practical existing implementations of BCD are typically slower than operations on binary representations, especially on embedded systems, due to limited processor support for native BCD operations.
  • Some operations are more complex to implement. Adders require extra logic to cause them to wrap and generate a carry early. Also, 15 to 20 per cent more circuitry is needed for BCD add compared to pure binary.{{Citation needed|date=May 2011}} Multiplication requires the use of algorithms that are somewhat more complex than shift-mask-add (a binary multiplication, requiring binary shifts and adds or the equivalent, per-digit or group of digits is required).
  • Standard BCD requires four bits per digit, roughly 20 per cent more space than a binary encoding (the ratio of 4 bits to log210 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 8-bit byte boundaries common on existing hardware, resulting in slower implementations on these systems.

Representational variations

Various BCD implementations exist that employ other representations for numbers. Programmable calculators manufactured by Texas Instruments, Hewlett-Packard, and others typically employ a floating-point 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

Signed decimal values may be represented in several ways. The COBOL programming language, for example, supports five zoned decimal formats, with each one encoding the numeric sign in a different way:{| class="wikitable" style="width:95%"! style="background:#D0E0FF; width:25%"| Type! style="background:#D0E0FF; width:55%"| Description! style="background:#D0E0FF; width:20%"| Example
Signed number representations>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

{{anchor|TBCD}}Telephony binary-coded decimal (TBCD)

3GPP developed TBCD, an expansion to BCD where the remaining (unused) bit combinations are used to add specific telephony characters, with digits similar to those found in telephone keypads original design.{| class="wikitable" style="width:30%; text-align:center"! style="background:#E0E0E0; width:50%" |Decimaldigit! style="background:#E0E0E0; width:50%" |TBCD8 4 2 1
! style="background:#F0F0F0" |*| 1 0 1 0
! style="background:#F0F0F0" |#| 1 0 1 1
! style="background:#F0F0F0" |a| 1 1 0 0
! style="background:#F0F0F0" |b| 1 1 0 1
! style="background:#F0F0F0" |c| 1 1 1 0
! style="background:#F0F0F0" |Used as filler when there is an odd number of digits| 1 1 1 1
The mentioned 3GPP document defines TBCD-STRING 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 2nbits 4321 of octet n encoding digit 2(n – 1) + 1Meaning number 1234, would become 21 43 in TBCD.

Alternative encodings

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 binary-encoded integer and a binary-encoded signed decimal exponent. For example, 0.2 can be represented as 2{{e|-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.The Hertz and Chen–Ho encodings provide Boolean transformations for converting groups of three BCD-encoded digits to and from 10-bit 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 754-2008 floating-point standard.

Application

The BIOS in many personal computers stores the date and time in BCD because the MC6818 real-time 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.The Atari 8-bit computers use a BCD format for floating point numbers. The MOS Technology 6502 processor has a BCD mode for the addition and subtraction instructions. The Psion Organiser 1 handheld computer's manufacturer-supplied software also uses BCD to implement floating point; later Psion models use 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.

Legal history

In the 1972 case Gottschalk v. Benson, the U.S. Supreme Court overturned a lower court's decision that had allowed a patent for converting BCD-encoded numbers to binary on a computer. The decision noted that a patent "would wholly pre-empt the mathematical formula and in practical effect would be a patent on the algorithm itself". This was a landmark judgement that determined the patentability of software and algorithms.

See also

Notes

References

.WEB, Intel, ia32 architecture manual,weblinkweblink" title="ghostarchive.org/archive/20221009weblink">weblink 2022-10-09, live, Intel, 2015-07-01, BOOK, Lexikon der Informatik und Datenverarbeitung, de, Hans-Jochen, Schneider, 1986, 2, R. Oldenbourg Verlag München Wien, 3-486-22662-2, BOOK, Einführung in die digitale Datenverarbeitung, de, Introduction to digital information processing, Hans Jörg, Tafel, Carl Hanser Verlag, 1971, Munich, 3-446-10569-7, BOOK, Taschenbuch der Nachrichtenverarbeitung, de, Karl W., Steinbuch, Karl W. Steinbuch, Erich R., Berger, 1.3.3. Die Codierung von Zahlen, 1962, 1, Springer-Verlag OHG, Karlsruhe, Germany, Berlin / Göttingen / New York, 62-14511, 68–75, (NB. The shown Kautz code (II), containing all eight available binary states with an odd count of 1s, is a slight modification of the REF, Kautz, 1954, original Kautz, plain, code (I), containing all eight states with an even count of 1s, so that inversion of the most-significant bits will create a 9s complement.)BOOK, Taschenbuch der Informatik - Band II - Struktur und Programmierung von EDV-Systemen, de, Karl W., Steinbuch, Karl W. Steinbuch, Wolfgang, Weber, Traute, Heinemann, 1974, 1967, 3, 2, Taschenbuch der Nachrichtenverarbeitung, Springer-Verlag, Berlin, Germany, 3-540-06241-6, 73-80607, BOOK, Advanced Electronic Circuits, Ulrich, Tietze, Christoph, Schenk, 2012-12-06, Springer Science & Business Media, 978-3642812415, 9783642812415,weblink 2015-08-05, BOOK, Nuclear Electronics, Emil, Kowalski, 2013-03-08, 1970, Springer-Verlag, 978-3642876639, 9783642876639, 978-3-642-87664-6, 10.1007/978-3-642-87663-9,weblink 2015-08-05, BOOK, Wörterbuch der Elektronik, Datentechnik und Telekommunikation / Dictionary of Electronics, Computing and Telecommunications: Teil 1: Deutsch-Englisch / Part 1: German-English, Vittorio, Ferretti, 2, 1, Springer-Verlag, 2013-03-13, 978-3642980886, 9783642980886,weblink 2015-08-05, BOOK, Ambrosius Paul, Speiser, Ambrosius Paul Speiser, Eidgenössische Technische Hochschule Zürich, ETH Zürich, Zürich, Switzerland, Digitale Rechenanlagen - Grundlagen / Schaltungstechnik / Arbeitsweise / Betriebssicherheit, de, Digital computers - Basics / Circuits / Operation / Reliability, 2, 1965, 1961, Springer-Verlag / IBM, 65-14624, 0978, 209, BOOK, Digital Electronics, Folkert, Dokter, Jürgen, Steinhauer, 1973-06-18, Philips Technical Library (PTL) / Macmillan Education, The Macmillan Press Ltd. / N. V. Philips' Gloeilampenfabrieken, Reprint of 1st English, Eindhoven, Netherlands, 333-13360-9, 978-1-349-01419-4, 10.1007/978-1-349-01417-0,weblinkweblink dead, 16 July 2020, 2020-05-11, (270 pages) (NB. This is based on a translation of volume I of the two-volume German edition.)BOOK, Folkert, Dokter, Jürgen, Steinhauer, Digitale Elektronik in der Meßtechnik und Datenverarbeitung: Theoretische Grundlagen und Schaltungstechnik, de, Philips Fachbücher, Deutsche Philips GmbH, Hamburg, Germany, I, 1975, 1969, improved and extended 5th, 3-87145-272-6, 50, (xii+327+3 pages) (NB. The German edition of volume I was published in 1969, 1971, two editions in 1972, and 1975. Volume II was published in 1970, 1972, 1973, and 1975.)BOOK, Digitale Automaten – Theorie, Struktur, Technik, Programmieren, de, Wilhelm, Kämmerer, :de:Wilhelm Kämmerer, Hans, Frühauf, :de:Hans Frühauf, Wilhelm, Kämmerer, Kurz, Schröder, Helmut, Winkler, II.15. Struktur: Informationsdarstellung im Automaten, 1, May 1969, Akademie-Verlag GmbH, Berlin, Germany, Jena, Germany, 5, License no. 202-100/416/69. Order no. 4666 ES 20 K 3., Elektronisches Rechnen und Regeln, 161,weblink (NB. A second edition 1973 exists as well.)WEB, Mike F., Cowlishaw, Mike F. Cowlishaw, General Decimal Arithmetic, 1981, 2008, 2015,weblink 2016-01-02, BOOK, Digitale Rechenautomaten – Eine Einführung, de, Digital Computers – An Introduction, 1.5.3 Konvertierung binär verschlüsselter Dezimalzahlen, 1.5.3 Conversion of binary coded decimal numbers, Rainer, Klar, Walter de Gruyter & Co. / {{ill, G. J. Göschen'sche Verlagsbuchhandlung, de, G. J. Göschen'sche Verlagsbuchhandlung, |location=Berlin, Germany |series=Sammlung Göschen |volume=1241/1241a |date=1970-02-01 |isbn=3-11-083160-0 |id=. Archiv-Nr. 7990709. |pages=17, 21 |edition=1 |url=https://books.google.com/books?id=QnqVDwAAQBAJ&pg=PA21 |access-date=2020-04-13 |url-status=live |archive-url=https://web.archive.org/web/20200418220658weblink |archive-date=2020-04-18}} (205 pages) (NB. A 2019 reprint of the first edition is available under {{ISBN|3-11002793-3|978-3-11002793-8}}. A reworked and expanded REF, Klar, 1989, 4th edition, plain, exists as well.)BOOK, Digitale Rechenautomaten – Eine Einführung in die Struktur von Computerhardware, de, Digital Computers – An Introduction into the structure of computer hardware, 1.4 Codes: Binär verschlüsselte Dezimalzahlen, 1.4 Codes: Binary coded decimal numbers, Rainer, Klar, Walter de Gruyter & Co., Berlin, Germany, Sammlung Göschen, 2050, 1989, 1988-10-01, 3-11011700-2, 25, 28, 38–39, 4th reworked, 25, […] Die nicht erlaubten 0/1-Muster nennt man auch Pseudodezimalen. […], (320 pages)BOOK, Microprocessors - A Programmer's View, Robert Berriedale Keith, Dewar, Robert Berriedale Keith Dewar, Matthew, Smosna, 1990, 1, McGraw-Hill Publishing Company, Courant Institute, New York University, New York, USA, 0-07-016638-2, 89-77320, 14, (xviii+462 pages)WEB, Decimal Representations, John J. G., Savard, 2018, 2006, quadibloc,weblink 2018-07-16, live,weblink" title="web.archive.org/web/20180716101321weblink">weblink 2018-07-16, JOURNAL, A New Representation for Decimal Numbers, Chun-Kwong, Yuen, IEEE Transactions on Computers, December 1977, C-26, 12, 10.1109/TC.1977.1674792, 40879271, 1286–1288,weblink 2020-08-08, live,weblink 2020-08-08, CONFERENCE, Optimized Data Encoding for Digital Computers, IV. Examples A. Binary Codes for Decimals, n = 4, Kautz, William H., William H. Kautz, Convention Record of the I.R.E., 1954 National Convention, Part 4 - Electronic Computers and Information Theory, I.R.E., Session 19: Information Theory III - Speed and Computation, June 1954, Stanford Research Institute, Stanford, California, USA, 47–57 [49, 51–52, 57],weblink 2020-07-03, live,weblink 2020-07-03, 52, […] The last column [of Table II], labeled "Best," gives the maximum fraction possible with any code—namely 0.60—half again better than any conventional code. This extremal is reached with the ten [heavily-marked vertices of the graph of #Kautz, 4, or, in fact, with any set of ten code combinations which include all eight with an even (or all eight with an odd) number of "1's." The second and third rows of Table II list the average and peak decimal change per undetected single binary error, and have been derived using the equations of Sec. II for Δ1 and δ1. The confusion index for decimals using the criterion of "decimal change," is taken to be cij = {{!, i − j{{!}}   i,j = 0, 1, … 9. Again, the "Best" arrangement possible (the same for average and peak), one of which is shown in Fig. 4, is substantially better than the conventional codes. […] Fig. 4 Minimum-confusion code for decimals. […] δ1=2   Δ1=15 […]}} weblink" title="https:/-/web.archive.org/web/20200703173707weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175038weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175214weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175243weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175313weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175344weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175425weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175459weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175529weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175606weblink">weblink weblink" title="https:/-/web.archive.org/web/20200703175641weblink">weblink (11 pages) (NB. Besides the combinatorial set of 4-bit BCD "minimum-confusion codes for decimals", of which the author illustrates only one explicitly (here reproduced as code I) in form of a 4-bit graph, the author also shows a 16-state 4-bit "binary code for analog data" in form of a code table, which, however, is not discussed here. The code II shown here is a modification of code I discussed by REF, Berger, 1962, Berger, plain, .)JOURNAL, A Decimal Code for Analog-to-Digital Conversion, Lippel, Bernhard, IRE Transactions on Electronic Computers, 0367-9950, EC-4, 4, December 1955, 10.1109/TEC.1955.5219487, 158–159, (2 pages)JOURNAL, Ermittlung des Codes und der logischen Schaltung einer Zähldekade, de, Herbert, Stopper, Wilhelm Tolmé, Runge, Wilhelm Tolmé Runge, March 1960, Telefunken-Zeitung (TZ) - Technisch-Wissenschaftliche Mitteilungen der Telefunken GMBH, 33, 127, Telefunken, Berlin, Germany, Litzelstetten, Germany, 13–19, (7 pages)BOOK, Digitale Meßtechnik: Eine Einführung, 2.3 Gebräuchliche Codes in der digitalen Meßtechnik, de, Lorenz, Borucki, Joachim, Dittmann, 1971, July 1970, 1966, Autumn 1965, Springer-Verlag, Berlin / Heidelberg, Germany, Krefeld / Karlsruhe, Germany, 2, 75-131547, 3-540-05058-2, {{ISBN, 978-3-642-80561-5, |doi=10.1007/978-3-642-80560-8 |pages=10–23 [12–14]}} (viii+252 pages) 1st editionBOOK, Design Methods for Digital Systems, Jean P., Chinal, Codes, en, Akademie-Verlag / Springer-Verlag, Berlin, Germany, Paris, France, Alan, Preston, Arthur, Summer, January 1973, 1st English, License No. 202-100/542/73. Order No. 7617470(6047) ES 19 B 1 / 20 K 3, 978-0-387-05871-9, 10.1007/978-3-642-86187-1_3, 46,weblink 2020-06-21, (xviii+506 pages) (NB. The French 1967 original book was named "Techniques Booléennes et Calculateurs Arithmétiques", published by {{ill|Éditions Dunod|fr}}.)BOOK, Frank, Gray, Frank Gray (researcher), Pulse Code Communication, 1953-03-17, 1947-11-13, Bell Telephone Laboratories, Incorporated, New York, USA, {{US patent, 2632058, . Serial No. 785697 |url=https://patentimages.storage.googleapis.com/a3/d7/f2/0343f5f2c0cf50/US2632058.pdf |access-date=2020-08-05 |url-status=live |archive-url=https://web.archive.org/web/20200805094312weblink |archive-date=2020-08-05}} (13 pages)JOURNAL, March 1957, Can You Take Advantage of the Cyclic Binary-Decimal Code?, Harry Robert, Glixon, Control Engineering (magazine), Control Engineering, 0010-8049, Technical Publishing Company, a division of Dun-Donnelley Publishing Corporation, Dun & Bradstreet Corp., 4, 3, 87–91,weblink (5 pages)JOURNAL, Coded Decimal Number Systems for Digital Computers, Garland S., White, Proceedings of the Institute of Radio Engineers, Institute of Radio Engineers (IRE), 0096-8390, 2162-6634, 41, 10, October 1953, 10.1109/JRPROC.1953.274330, 51674710, 1450–1452, (3 pages)JOURNAL, Harold M., Lucal, Arithmetic Operations for Digital Computers Using a Modified Reflected Binary, IRE Transactions on Electronic Computers, EC-8, 4, 449–458, December 1959, 0367-9950, 10.1109/TEC.1959.5222057, 206673385,weblink (10 pages)WEB, Different Types of Binary Codes, Section 2.4 5211 Code, 2019-05-01, 2015-01-28, Electronic Hub,weblink 2020-08-04, live,weblink 2020-05-18, WEB, Matthias R., Paul, Unterbrechungsfreier Schleifencode, de, Continuous loop code, 1.02,weblink 1995-08-10, 1994, 2008-02-11, {{cbignore}} (NB. The author called this code (English: "loop code"). It differs from Gray BCD code only in the encoding of state 0 to make it a cyclic unit-distance code for full-circle rotatory slip ring applications. Avoiding the all-zero code pattern allows for loop self-testing and to use the data lines for uninterrupted power distribution.)BOOK, Edward John, Petherick, A Cyclic Progressive Binary-coded-decimal System of Representing Numbers, October 1953, Technical Note MS15, Royal Aircraft Establishment (RAE), Farnborough, UK, (4 pages) (NB. Sometimes referred to as A Cyclic-Coded Binary-Coded-Decimal System of Representing Numbers.)BOOK, Edward John, Petherick, A. J., Hopkins, Some Recently Developed Digital Devices for Encoding the Rotations of Shafts, 1958, Technical Note MS21, Royal Aircraft Establishment (RAE), Farnborough, UK, JOURNAL, Joseph A., O'Brien, Cyclic Decimal Codes for Analogue to Digital Converters, (Transactions of the American Institute of Electrical Engineers, Part I: Communication and Electronics), Bell Telephone Laboratories, Whippany, New Jersey, USA, 75, 2, May 1956, 1955-11-15, 1955-06-23, 0097-2452, 10.1109/TCE.1956.6372498, Paper 56-21, 51657314, 120–122,weblink 2020-05-18, (3 pages) (NB. This paper was prepared for presentation at the AIEE Winter General Meeting, New York, USA, 1956-01-30 to 1956-02-03.)JOURNAL, Howard E., Tompkins, Unit-Distance Binary-Decimal Codes for Two-Track Commutation, September 1956, 1956-07-16, IRE Transactions on Electronic Computers, 0367-9950, EC-5, 3, 10.1109/TEC.1956.5219934, Correspondence, Moore School of Electrical Engineering, University of Pennsylvania, Philadelphia, Pennsylvania, USA, 139,weblink 2020-05-18, (1 page)BOOK, Notes on Analog-Digital Conversion Techniques, III.F. Unit-Distance Codes / VI.E.2. Reflected Binary Codes, Alfred Kriss, Susskind, Alfred Kriss, Susskind, John Erwin, Ward, 1958-03-28, 1957, 1956, 3, Technology Press of the Massachusetts Institute of Technology / John Wiley & Sons, Inc. / Chapman & Hall, Ltd., New York, USA, Cambridge, Massachusetts, USA, Technology Books in Science and Engineering, 1, 3-7–3-8 [3-7], 3-10–3-16 [3-13–3-16], 6-65–6-60 [6-60], (x+416+2 pages) (NB. The contents of the book was originally prepared by staff members of the Servomechanisms Laboraratory, Department of Electrical Engineering, MIT, for Special Summer Programs held in 1956 and 1957. The code Susskind actually presented in his work as "reading-type code" is shown as code type II here, whereas the type I code is a minor derivation with the two most significant bit columns swapped to better illustrate symmetries.)BOOK, Military Handbook: Encoders - Shaft Angle To Digital, United States Department of Defense, MIL-HDBK-231A, 1991-09-30,weblink 2020-07-25, live,weblink" title="web.archive.org/web/20200725051128weblink">weblink 2020-07-25, (NB. Supersedes MIL-HDBK-231(AS) (1970-07-01).)BOOK, Parag K., Lala, Principles of Modern Digital Design, 2007, John Wiley & Sons, 978-0-470-07296-7, 20–25,weblink BOOK, IBM System/370 Principles of Operation, Chapter 8: Decimal Instructions, IBM, March 1980, BOOK, PDP-11 Architecture Handbook, Chapter 3: Data Representation, Digital Equipment Corporation, 1983, BOOK, VAX-11 Architecture Handbook, Digital Equipment Corporation, 1985, WEB,weblink ILE RPG Reference, IBM BM 1401/1440/1460/1410/7010 Character Code Chart in BCD Order{{dead link|date=November 2016 |bot=InternetArchiveBot |fix-attempted=yes}}BOOK, Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture, 4.7 BCD and packed BCD integers, 1, Version 072, 3-2, 4-9–4-11 [4-10], 2020-05-27, 1997, 253665-072US, Intel Corporation,weblink 2020-08-06, live,weblink 2020-08-06, 4-10, […] When operating on BCD integers in general-purpose registers, the BCD values can be unpacked (one BCD digit per byte) or packed (two BCD digits per byte). The value of an unpacked BCD integer is the binary value of the low Nibble, halfbyte (bits 0 through 3). The high half-byte (bits 4 through 7) can be any value during addition and subtraction, but must be zero during multiplication and division. Packed BCD integers allow two BCD digits to be contained in one byte. Here, the digit in the high half-byte is more significant than the digit in the low half-byte. […] When operating on BCD integers in x87 floating-point unit, positive and 1 = negative; bits 0 through 6 of byte 10 are don't-care term, don't care bits). Negative decimal integers are not stored in two's complement form; they are distinguished from positive decimal integers only by the sign bit. The range of decimal integers that can be encoded in this format is −1018 + 1 to 1018 − 1. The decimal integer format exists in memory only. When a decimal integer is loaded in an x87 FPU data register, it is automatically converted to the double-extended-precision floating-point format. All decimal integers are exactly representable in double extended-precision format. […], weblinkWEB, The 68000's Instruction Set,weblink 2023-11-21, live,weblink" title="web.archive.org/web/20231120233850weblink">weblink 2023-11-20, (58 pages)WEB, BCD Arithmetic, a tutorial, Arithmetic Tutorials, Douglas W., Jones, Douglas W. Jones, The University of Iowa, Department of Computer Science, 1999, 2015-11-25, Iowa City, Iowa, USA,weblink 2016-01-03, WEB, University of Alicante, A Cordic-based Architecture for High Performance Decimal Calculations,weblinkweblink" title="web.archive.org/web/20100105044510weblink">weblink 2010-01-05, live, IEEE, 2015-08-15, WEB, Decimal CORDIC Rotation based on Selection by Rounding: Algorithm and Architecture,weblinkweblink" title="ghostarchive.org/archive/20221009weblink">weblink 2022-10-09, live, British Computer Society, 2015-08-14, BOOK, Mathur, Aditya P.,weblink Introduction to Microprocessors, 3, 1989, Tata McGraw-Hill Publishing Company Limited, 978-0-07-460222-5, TECH REPORT, 3GPP TS 29.002: Mobile Application Part (MAP) specification, sec. 17.7.8 Common data types, 2013,weblink WEB,weblinkweblink" title="web.archive.org/web/20131204061024weblink">weblink 2013-12-04, live, Signalling Protocols and Switching (SPS) Guidelines for using Abstract Syntax Notation One (ASN.1) in telecommunication application protocols, 15, WEB,weblink XOM Mobile Application Part (XMAP) Specification, 93, 2013-06-27,weblink" title="web.archive.org/web/20150221103429weblink">weblink 2015-02-21, dead, WEB, Timer Counter Circuits in an IBM PC, Week 8, www.se.ecu.edu.au,weblink 2022-05-22, dead,weblink" title="web.archive.org/web/20081010064411weblink">weblink 2008-10-10, (7 pages)MC6818 datasheet{{anchor|Ferranti}}BOOK, Digital Data: Their derivation and reduction for analysis and process control, Chapter Four: Ancillary Equipment: Output-drive and parity-check relays for digitizers, David Silvester, Evans, 1, Hilger & Watts Ltd / Interscience Publishers, London, UK, March 1961, 46–64 [56–57],weblink 2020-05-24, (8+82 pages) (NB. The 4-bit 8421 BCD code with an extra parity bit applied as least significant bit to achieve odd parity of the resulting 5-bit code is also known as Ferranti code.)BOOK, Digital Computer and Control Engineering, Part 4. Logical Design of Digital-Computer Circuitry; Chapter 15. Serial Arithmetic Operations; Chapter 15-7. Additional Topics, Robert Steven, Ledley, Robert Steven Ledley, Louis S., Rotolo, James Bruce, Wilson, McGraw-Hill Book Company, Inc. (printer: The Maple Press Company, York, Pennsylvania, USA), New York, USA, McGraw-Hill Electrical and Electronic Engineering Series, 1, 1960, 07036981-X, 0-07036981-X, . ark:/13960/t72v3b312, 2574-7916, OL5776493M, 59015055, 1033638267, 517–518,weblink 2021-02-19, live,weblink" title="web.archive.org/web/20210219203314weblink">weblink 2021-02-19, 517, […] The cyclic code is advantageous mainly in the use of relay circuits, for then a sticky relay will not give a false state as it is delayed in going from one cyclic number to the next. There are many other cyclic codes that have this property. […], weblink (xxiv+835+1 pages) (NB. Ledley classified the described cyclic code as a cyclic decimal-coded binary code.)}}

Further reading

  • BOOK,weblink Coded Character Sets, History and Development, The Systems Programming Series, Mackenzie, Charles E., 1980, 1, Addison-Wesley Publishing Company, Inc., 978-0-201-14460-4, 77-90165, 2019-08-25,weblink May 26, 2016, live, mdy-all,
  • BOOK, Richard Kohler, Richards, Arithmetic Operations in Digital Computers, van Nostrand (publisher), van Nostrand, New York, USA, 1955, 397–,
  • BOOK, Decimal Computation, Hermann, Schmid, Hermann Schmid (computer scientist), 1974, 1, John Wiley & Sons, Binghamton, New York, USA, 0-471-76180-X, registration,weblink and BOOK, Decimal Computation, Hermann, Schmid, Hermann Schmid (computer scientist), 1974, 1983, 1 (reprint), Robert E. Krieger Publishing Company, Malabar, Florida, USA, 0-89874-318-4, (NB. At least some batches of the Krieger reprint edition were misprints with defective pages 115–146.)
  • JOURNAL, Henry, Massalin, Superoptimizer: A look at the smallest program, ACM Sigops Operating Systems Review, Henry Massalin, Randy, Katz, Randy Katz, 122–126, 10.1145/36204.36194, October 1987, 21, 4, 0-8186-0805-6,weblink 2012-04-25, live,weblink 2017-07-04, (Also: ACM SIGPLAN Notices, Vol. 22 10, IEEE Computer Society Press 87CH2440-6, October 1987)
    • WEB, GNU Superoptimizer, HP-UX,weblink
  • CONFERENCE, VLSI designs for redundant binary-coded decimal addition, Behrooz, Shirazi, David Y. Y., Yun, Chang N., Zhang, IEEE Seventh Annual International Phoenix Conference on Computers and Communications, 1988, 52–56, IEEE, March 1988,
  • BOOK, Fundamentals of Digital Logic, 2003, Brown, Vranesic,
  • CONFERENCE, Modified Carry Look Ahead BCD Adder With CMOS and Reversible Logic Implementation, Himanshu, Thapliyal, Hamid R., Arabnia, Proceedings of the 2006 International Conference on Computer Design (CDES'06), 1-60132-009-4, 64–69, CSREA Press, November 2006,
  • CONFERENCE, Reversible Implementation of {{Sic, y, Densely, -, Packed-Decimal Converter to and from Binary-Coded-Decimal Format Using in IEEE-754R |author-first1=A. |author-last1=Kaivani |author-first2=A. Zaker |author-last2=Alhosseini |author-first3=S. |author-last3=Gorgin |author-first4=M. |author-last4=Fazlali |conference=9th International Conference on Information Technology (ICIT'06) |pages=273–276 |publisher=IEEE |date=December 2006}}
  • WEB, Mike F., Cowlishaw, Mike F. Cowlishaw, Bibliography of material on Decimal Arithmetic – by category, General Decimal Arithmetic, 2002, 2008, IBM, 2009,weblink 2016-01-02,

External links



- content above as imported from Wikipedia
- "Binary-coded decimal" does not exist on GetWiki (yet)
- time: 7:18am EDT - Sat, May 18 2024
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
GETWIKI 23 MAY 2022
GETWIKI 09 JUL 2019
Eastern Philosophy
History of Philosophy
GETWIKI 09 MAY 2016
GETWIKI 18 OCT 2015
M.R.M. Parrott
Biographies
GETWIKI 20 AUG 2014
CONNECT