Signed overpunch


A signed overpunch is a code used to store the sign of a number by changing the last digit. It is used in character data on IBM mainframes by languages such as COBOL, PL/I, and RPG. Its purpose is to save a character that would otherwise be used by the sign digit. The code is derived from the Hollerith Punched Card Code, where both a digit and a sign can be entered in the same card column. It is called an overpunch because the digit in that column has a 12-punch or an 11-punch above it to indicate the sign. Character data which may contain overpunches is called zoned decimal.
The PACK instruction on IBM System/360 architecture machines converts the sign of a zoned decimal number when converting to packed decimal,
and the corresponding UNPK instruction will set the correct overpunched sign of its zoned decimal output.

Language support

PL/I

PL/I uses the PICTURE attribute to declare zoned decimal data with a signed overpunch. Each character in a numeric picture except V, which indicates the position of the assumed decimal point, represents a digit. A picture character of T, I, or R indicates a digit position which may contain an overpunch. T indicates that the position will contain –R if negative. I indicates that the position will contain –R if negative.
For example PICTURE 'Z99R' describes a four-character numeric field. The first position may be blank or will contain a digit 0–9. The next two positions will contain digits, and the fourth position will contain 0–9 for a positive number and

COBOL

COBOL uses the picture character 'S' for USAGE IS DISPLAY data without SIGN IS SEPARATE CHARACTER to indicate an overpunch. SIGN IS LEADING indicates that the overpunch is over the first character of the field, the default, SIGN IS TRAILING, locates it over the last character. SIGN IS TRAILING is the default.

C/C++

The C language has no provision for zoned decimal. The IBM ILE C/C++ compiler for System i provides functions for conversion between int or double and zoned decimal:

Examples

10

ASCII representation

COBOL representation of signed overpunch characters "is not standardized in ASCII, and different compilers use different overpunch codes." In most cases, "the representation is not the same as the result of converting an EBCDIC Signed field to ASCII with a translation table." PL/I compilers on ASCII systems use the same set of characters as in EBCDIC to represent overpunches.