Signed overpunch
In the realm of computing, a signed overpunch refers to a data encoding technique that represents the sign of a numerical value by modifying its final digit, typically. This method is commonly employed in character data on IBM mainframe systems, utilized by programming languages such as COBOL, PL/I, and RPG. Its primary function is to eliminate the need for a separate character dedicated solely to the sign. The origin of this encoding traces back to the Hollerith Punched Card Code, which allowed both a digit and its sign to be recorded within the same column of a punched card. The term "overpunch" arises because the digit receives an additional punch—either a 12-punch or 11-punch—above it to denote the sign. The upper three rows on the punched card are known as zone punches, and numeric data encoded with overpunches is classified as zoned decimal.
Within IBM's technical framework, a byte's lower four bits represent the digit, while the upper four bits correspond to the zone. The digit bits encode values ranging from 0 to 9. The zone bits may be 'F'x, which produce characters 0 through 9, or other hexadecimal values that signify positive or negative signs: zones A, C, E, and F indicate positivity; zones B and D signify negativity.
The PACK instruction on IBM System/360 architecture systems converts the sign information from zoned decimal numbers into packed decimal format. Conversely, UNPK restores the appropriate overpunched sign in zoned decimal outputs.
PL/I
In PL/I, zoned decimal data with signed overpunches is declared using the PICTURE attribute. Each character in a numeric picture string corresponds to a digit except for V, which specifies an implied decimal point. Characters such as T, I, or R designate positions where an overpunch may appear. For instance, PICTURE 'Z99R' defines a four-character numeric field where the final position holds digits 0–9 for positive values and negative values are represented by {–R.
Assigning the value 1021 results in the string "1021"; assigning -1021 yields "102J".
COBOL
In COBOL, an overpunch is indicated by using the picture character 'S' for USAGE IS DISPLAY data without specifying SIGN IS SEPARATE CHARACTER. When SIGN IS LEADING is used, the overpunch appears on the first character; if SIGN IS TRAILING (which is default), it is placed on the last character.
C/C++
The standard C language does not inherently support zoned decimal formats. Nevertheless, IBM's ILE C/C++ compiler for System i provides specialized functions to convert between standard types like int, double, and zoned decimal representations:
- QXXDTOZ() — Converts Double to Zoned Decimal
- QXXITOZ() — Converts Integer to Zoned Decimal
- QXXZTOD() — Converts Zoned Decimal to Double
- QXXZTOI() — Converts Zoned Decimal to Integer
EBCDIC overpunch codes
| EBCDIC character |
Digit | Sign | Card code |
|---|---|---|---|
| { | 0 | + | 12-0 |
| A | 1 | + | 12-1 |
| B | 2 | + | 12-2 |
| C | 3 | + | 12-3 |
| D | 4 | + | 12-4 |
| E | 5 | + | 12-5 |
| F | 6 | + | 12-6 |
| G | 7 | + | 12-7 |
| H | 8 | + | 12-8 |
| I | 9 | + | 12-9 |
| } | 0 | - | 11-0 |
| J | 1 | - | 11-1 |
| K | 2 | - | 11-2 |
| L | 3 | - | 11-3 |
| M | 4 | - | 11-4 |
| N | 5 | - | 11-5 |
| O | 6 | - | 11-6 |
| P | 7 | - | 11-7 |
| Q | 8 | - | 11-8 |
| R | 9 | - | 11-9 |
Examples
10} denotes -100 45A denotes 451
ASCII representation
Signed overpunch characters do not have a uniform ASCII equivalent; different compilers assign distinct codes. Occasionally, ASCII values differ from those generated by EBCDIC-to-ASCII conversion, which can impact the compatibility of source data and the interpretation of numeric digits.
For instance, a negative EBCDIC field concluding with the digit '1' is encoded as 'D1'x (uppercase 'J'), where the 'D' signifies a negative value. The uppercase ASCII 'J' ('4A'x) does not correspond to any numeric value. Conversely, lowercase 'q' ('71'x) maintains both digit identity and sorting order but demands specialized translation procedures for overpunched fields.
Examples
Gnu COBOL and MicroFocus COBOL represent negative digits '0' through '9' using lowercase letters from 'p' to 'y'.
On ASCII platforms, PL/I compilers utilize the same character set ({, J–R) as in EBCDIC to indicate overpunches.