Lably
Skip to content

Signed overpunch

  • 3 min read
  • 4 chapters

Related on Lably

Through Sign (mathematics) and COBOL

In IBM terminology, the low-order four bits of a byte in storage are called the digit, and the high-order four bits are the zone. The digit bits contain the numeric value 0–9. The zone bits contain either 'F'x, forming the characters 0–9, or the character position containing the overpunch contains a hexadecimal value indicating a positive or negative value, forming a different set of characters. (A, C, E, and F zones indicate positive values, B and D negative).

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 {–I if positive and {–R if negative. I indicates that the position will contain {–I if positive and 0-9 if negative. R indicates that the position will contain 0–9 if positive and {–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 {–R for negative.

Assigning the value 1021 to the above picture will store the characters "1021" in memory; assigning -1021 will store "102J".

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. 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:

  • QXXDTOZ() — Convert Double to Zoned Decimal
  • QXXITOZ() — Convert Integer to Zoned Decimal
  • QXXZTOD() — Convert Zoned Decimal to Double
  • QXXZTOI() — Convert Zoned Decimal to Integer

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and information technology