Sign in

docs RPG Reference

Integer Format

Integer Format

The integer format is similar to the binary format with two exceptions:

  • The integer format allows the full range of binary values
  • The number of decimal positions for an integer field is always zero.

You define an integer field by specifying the INT keyword in a free-form definition, or by specifying I in the Data-Type entry of the appropriate specification. You can also define an integer field using the LIKE keyword on a definition specification where the parameter is an integer field.

The length of an integer field is defined in terms of number of digits; it can be 3, 5, 10, or 20 digits long. A 3-digit field takes up 1 byte of storage; a 5-digit field takes up 2 bytes of storage; a 10-digit field takes up 4 bytes; a 20-digit field takes up 8 bytes. The range of values allowed for an integer field depends on its length.

Field length : Range of Allowed Values

3-digit integer : -128 to 127

5-digit integer : -32768 to 32767

10-digit integer : -2147483648 to 2147483647

20-digit integer : -9223372036854775808 to 9223372036854775807

Note the following about integer fields:

  • Alignment of integer fields may be desired to improve the performance of accessing integer subfields. You can use the ALIGN keyword to align integer subfields defined on a definition specification.

    2-byte integer subfields are aligned on a 2-byte boundary; 4-byte integer subfields are aligned along a 4-byte boundary; 8-byte integer subfields are aligned along an 8-byte boundary. For more information on aligning integer subfields, see ALIGN{(*FULL)}.

  • If the LIKE keyword is used to define a field like an integer field, the Length entry may contain a length adjustment in terms of number of digits. The adjustment value must be such that the resulting number of digits for the field is 3, 5, 10, or 20.

  • Integer input fields cannot be defined as match or control fields.