ppQuentin
ppQuentin

Reputation:

What should be my standard choice of integer type in RPGLE?

When I want an integer in an RPGLE program, what data type should I choose? I'm talking about an integer that doesn't correspond to any field in the database, just a normal general purpose integer - kind of the equivalent of an int in Java.

Upvotes: 4

Views: 4143

Answers (2)

Tracy Probst
Tracy Probst

Reputation: 1859

Here's a chart from the ILE RPG Programmer's reference guide:

byte -  3I 0  (1-byte integer)
short-  5I 0  (2-byte integer)
int  - 10I 0  (4-byte integer)
long - 20I 0  (8-byte integer)

I use the 10I 0 form of integer most often. You'll find it's used in most of your API calls as well.

Upvotes: 9

Paul Morgan
Paul Morgan

Reputation: 32528

You can use the binary (signed integer) (B) or integer (unsigned integer) (I) types. You can specify the size with the digit values of 3 (1 byte), 5 (2 bytes), 10 (4 bytes) or 20 (8 bytes). The equivalent of a Java int would be 10B.

Upvotes: -2

Related Questions