classAnova - Knowledge Shared

Posted by: Bob Cozzi
IT Researcher
Cozzi Productions, Inc.
North Aurora, IL
Bob Cozzi's RPG IV Cheat Sheets
has no ratings.
Published: 08 Feb 2011
Revised: 04 Aug 2011 - 4143 days ago
Last viewed on: 07 Dec 2022 (13938 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Bob Cozzi's RPG IV Cheat Sheets Published by: Bob Cozzi on 08 Feb 2011 view comments

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


As Declared in RPG IV Conventional Identification IBM i (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 in RPG IV.

Old RPGIII RPG IV Integer Format in Memory
4B 0  5i 0
0 0
0 0
9B 0 10i 0
0 0 0 0
0 0 0 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:


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:

  • Fields of data type "B" with lengths 1 through 4 are converted to 5-digit "I" fields (5i 0).
  • Fields of data type "B" with lengths 5 through 9 are converted to 10-digit "I" fields (10i 0).

By specifying the EXTBININT keyword, your program can make use of the full range of binary fields in the Database. The range of Database 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.

Return to home page.
Sort Ascend | Descend