BCD (character encoding)
BCD, also called alphanumeric BCD, alphameric BCD, BCD Interchange Code, or BCDIC, is a family of representations of numerals, uppercase Latin letters, and some special and control characters as six-bit character codes.
Unlike later encodings such as ASCII, BCD codes were not standardized. Different computer manufacturers, and even different product lines from the same manufacturer, often had their own variants, and sometimes included unique characters. Other six-bit encodings with completely different mappings, such as some FIELDATA variants or Transcode, are sometimes incorrectly termed BCD.
Many variants of BCD encode the characters '0' through '9' as the corresponding binary values.
History
Technically, binary-coded decimal describes the encoding of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four.With the introduction of the IBM card in 1928, IBM created a code capable of representing alphanumeric information, later adopted by other manufacturers. This code represents the numbers 0-9 by a single punch, and uses multiple punches for upper-case letters and special characters. A letter has two punches ; most special characters have two or three punches.
The BCD code is the adaptation of the punched card code to a six-bit binary code by encoding the digit rows into the low four bits, and the zone rows into the high two bits. The digit zero is usually handled specially in some way, and the digit code was extended to values 10 through 15 by combining a digit in the range 2–7 with a punch in row 8. IBM applied the terms binary-coded decimal and BCD to the variations of BCD alphamerics used in most early IBM computers, including the IBM 1620, IBM 1400 series, and non-Decimal Architecture members of the IBM 700/7000 series.
Among the vendors using BCD were Burroughs, Bull, CDC, IBM, General Electric, NCR, Siemens, and Sperry-UNIVAC.
IBM announced the 8-bit Extended Binary Coded Decimal Interchange Code, based on BCDIC, in 1964 with the introduction of its System/360 line.
Special characters
The Recordmark or Record mark character is a character used to mark the end of a record. The BCD code for this character is 328 in some BCD variants. The closest Unicode equivalent is, but that is not found in many fonts, so is often used instead. Functionally this corresponds to the EBCDIC IRS character, X'1E'.The Groupmark or Group mark character is a character used to indicate the start or finish of a group of related fields. The BCD code for this character is 778 in some BCD variants. The groupmark was proposed for Unicode standardization in 2015, and was assigned to value. Functionally this corresponds to the EBCDIC IGS character, X'1D'. It is now in Unicode 10.0 at this position, but only the Symbola and Unifont fonts support it.
The Wordmark, by contrast, is not a BCD character. Rather, it is a flag bit used to mark the end of a word on some variable word length computers such as the IBM 1401.
BCD code variations
There are many different versions of the six-bit BCD code. There are three major categories of difference:- The mapping from zone punches to high-order bits. All codes translate no zone punches to a bit pattern of 00, but some encode the zone punches in 12-11-0 order, preserving alphabetical order, while others use 0-11-12 order, resulting in a partially reversed alphabet.
- The handling of the digit 0. The straightforward translation from punched form would place the blank before digits 1-9, and encode 0 somewhere else entirely. All codes have some special-case handling which either translates the digit 0 to the all-zero binary code, or gives it binary code 001010 and uses the 8+2 punch elsewhere.
- The assignment of special characters. The characters assigned to codes beyond the basic alphanumeric set varied widely, even within one model of computer.
Examples of BCD codes
The following charts show the numeric values of BCD characters in hexadecimal notation, as that most clearly reflects the structure of 4-bit binary coded decimal, plus two extra bits. For example, the code for 'A', in row 3x and column x1, is hexadecimal 31, or binary '11 0001'.48-character BCD code
The first versions of BCDIC had 48 characters, as they were based on card punch patterns and the character sets of printers, neither of which encouraged having a power-of-two number of characters.x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | # | @ | |||
1x | / | S | T | U | V | W | X | Y | Z | , | % | |||||
2x | - | J | K | L | M | N | O | P | Q | R | $ | |||||
3x | & | A | B | C | D | E | F | G | H | I | . |
This was based on a 40-character punched card code; the original 37, plus three commercially important characters added around 1932: hyphen-minus used for printing credit balances and hyphenated names, the ampersand also used in many names and addresses, and the asterisk used to overprint unused fields when printing cheques.
IBM 704 BCD code
The IBM 704 reordered the BCDIC code to allow a normal alphabetic collating order internally, with 0 before 1 and A before Z. It could automatically translate between this internal form and the earlier BCDIC when reading and writing magnetic tapes.The following table shows the code assignments for the IBM 704 computer. Unassigned code positions appear as blanks.
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | # | @ | ||||
1x | & | A | B | C | D | E | F | G | H | I | . | |||||
2x | - | J | K | L | M | N | O | P | Q | R | $ | |||||
3x | space | / | S | T | U | V | W | X | Y | Z | ‡ | , | % |
The following table shows the code assignments for the type 716 printer used starting with the IBM 704 computer and through the 7094. The 704 interface sent virtual punched-card rows to this printer, two words at a time, so the mapping from 6-bit BCD characters was done by software, and was not built into the printer.
This is a repertoire of 45 characters, as the characters
+
, -
and *
are duplicated.Fortran character set
There was some variation; IBM 704 Fortran had a different set of special characters.A similar code was used for the IBM 709, 7090 and 7094 successors, but with some of the special characters reassigned:
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | = | " | ||||
1x | & | A | B | C | D | E | F | G | H | I | . | ) | ||||
2x | - | J | K | L | M | N | O | P | Q | R | $ | |||||
3x | space | / | S | T | U | V | W | X | Y | Z | ± | , | ( |
IBM 1401 BCD code
The IBM 1401 used the all-zero code for blank, and moved the digit zero to the code 10. It had defined character forms for all possible values, for documentation purposes, but only 48 of the 63 non-blank characters were printable, and there was considerable variation in how the other code values were depicted in practice. Even the other characters varied between different available print chains for the IBM 1403 printer.x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | # | @ | : | > | √ |
1x | ¢ | / | S | T | U | V | W | X | Y | Z | ‡ | , | % | = | ' | " |
2x | - | J | K | L | M | N | O | P | Q | R | ! | $ | ) | ; | Δ | |
3x | & | A | B | C | D | E | F | G | H | I | ? | . | ( | < | ⯒ |
GBCD code
Below is the table of GE/Honeywell's GBCD code, a variant of BCD.x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ; | ' | ||||
3x | + | / | S | T | U | V | W | X | Y | Z | _ | , | % | = | " | ! |
Burroughs B5500 BCD code
The following table shows the code assignments for the Burroughs B5500 computer, sometimes referred to as BIC.x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | # | @ | ? | : | > | ≥ |
1x | + | A | B | C | D | E | F | G | H | I | . | " |
Code page 353
The BCDIC-A Code page was assigned as Code page 353, also known as CP353. Some of the characters in this code page are not in Unicode.x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | # | @ | : | > | √ |
1x | ␢ | / | S | T | U | V | W | X | Y | Z | ‡ | , | % | γ | \ | ⧻ |
2x | - | J | K | L | M | N | O | P | Q | R | ! | # | ] | ; | Δ | |
3x | & | A | B | C | D | E | F | G | H | I | ? | . | < | ⯒ |
At 0x1A is the [record mark, which was not proposed separately due to its similarity to the double dagger. At 0x3F is the group mark.
PTTC/BCD code pages
PTTC/BCD had 5 options. There were five code pages. They are shown below.The PTTC/BCD Standard Option was assigned as Code page 355, or CP355.
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | # | ||||
1x | @ | / | S | T | U | V | W | X | Y | Z | ‡ | , | γ | |||
2x | - | J | K | L | M | N | O | P | Q | R | < | $ | ||||
3x | & | A | B | C | D | E | F | G | H | I | ) | . |
The PTTC/BCD H Option was assigned as Code page 357, or CP357.
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | = | ||||
1x | ' | / | S | T | U | V | W | X | Y | Z | ‡ | , | ||||
2x | - | J | K | L | M | N | O | P | Q | R | ! | $ | ||||
3x | + | A | B | C | D | E | F | G | H | I | ? | . |
The PTTC/BCD Correspondence Option was assigned as Code page 358, or CP358.
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ' | ||||
1x | ! | / | S | T | U | V | W | X | Y | Z | ‡ | , | ||||
2x | - | J | K | L | M | N | O | P | Q | R | < | ; | ||||
3x | = | A | B | C | D | E | F | G | H | I | > | . |
The PTTC/BCD Monocase Option was assigned as Code page 359, or CP359.
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | # | ||||
1x | @ | / | S | T | U | V | W | X | Y | Z | , | |||||
2x | - | J | K | L | M | N | O | P | Q | R | $ | |||||
3x | & | A | B | C | D | E | F | G | H | I | . |
The PTTC/BCD Duocase Option was assigned as Code page 360, or CP360.
x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
0x | space | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | # | ||||
1x | @ | / | S | T | U | V | W | X | Y | Z | , | |||||
2x | - | J | K | L | M | N | O | P | Q | R | $ | |||||
3x | & | A | B | C | D | E | F | G | H | I | . |