Range and Use of the Integer (I) Data Types in RPG IV

As Declared In RPG IV Conventional Identification OS/400 API Doc C and Java Digits

Capacity Range

Signed Unsigned Signed Unsigned
3i 0 3u0 INT1 Bin(1) char 3 -128 to 127 0 to 255
5i 0 5u0 INT2 Bin(2) short 5 -32 768 to 32 767 0 to 65535
10i 0 10u0 INT4 Bin(4) int or long 10 -2 147 483 648 to 2 147 483 647 0 to 4 294 967 295
20i 0 20u0 INT8 Bin(8) long long 19 or 20 -9 223 372 036 854 775 808 to
9 223 372 036 854 775 807
0 to 18 446 744 073 709 551 615

The integer data type replaces the age-old "B" (binary) data type in RPG IV. New RPG IV code should only use the "I" data type, for the following reasons:

  1. The range of values for the "B" data type is artificially limited by RPG and "B" data-types.
  2. The "B" data-type is the slowest numeric data-types on the system, hundreds and often thousands of times slower than "I" data types.
  3. OS/400 APIs, C functions and V5R3 of CL use only "I" data-types. "B" data-types are an RPGIII-exclusive.

The following chart illustrates the correlation between the "B" data type and the "I" data type.

Old RPGIII RPG IV
4B 0  5i 0
9B 0 10i 0

On the Header specification in RPG IV, the EXTBININT keyword can be used to convert fields in database files from data type "B" to data type "I". Here is the syntax for this keyword:

EXTBININT{(*NO | *YES)}

The EXTBININT keyword is used to convert externally described fields with the "B" data type and with no decimal positions to integer format. If EXTBININT or EXTBININT(*YES) is specified, then an externally described field is processed as follows:

By specifying the EXTBININT keyword, your program can make use of the full range of DDS binary values available. (The range of DDS binary values is the same as for signed integers: -32768 to 32767 for a 5-digit field or -2147483648 to 2147483647 for a 10-digit field.)

[ back ]