Creating an integer in RPGLE

345300 pts.
Tags:
Integer
RPGLE
Looking for a way to create an integer in RPGLE in a way that is similar to the int command in Java. Is there anything like this?

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb

    Discussion: http://search400.techtarget.com/tip/Making-sense-of-integer-representation-in-RPG-code

    Either of these D-spec declarations

    D myInteger1 S 4b 0
    D myInteger2 S 10i 0

     

     

     

    49,850 pointsBadges:
    report
  • TomLiotta

    The linked article is incorrect in its reference to the 'B' data type:

    In past releases of OS/400, it was common to represent integer data as 4B 0 fields (4 byte binary integer). Many of the IBM API manuals still reference a 2- or 4-byte binary representation,...

    A [4B 0] declaration does not represent a "4 byte binary integer". It means that values will be stored in binary integer format and that the maximum value cannot exceed four decimal digits. An actual "4 byte binary integer" can hold values much larger than 9999. A [4B 0] declaration is much more like a "2 byte binary integer", though it's still limited to 9999 as a maximum value.

    The IBM API documents correctly refer to "4 byte binary integer" variables and are not related directly to RPG's [4B 0] declarations. The nearly equivalent RPG 'B' data type declaration would require having starting and ending positions rather than a single 'length' specification.

    For reasons like that, the [4B 0] notation probably should never be used nowadays. Use 'I' data types for signed integers and 'U' for unsigned integers. The 'B' data type has only a very few specific uses in current RPG coding. It can be used as a way precisely to include fractional decimal digits in memory while using a kind of binary integer memory format. (It's not clear why anyone would need to do that rather than use packed-decimal.)

    Tom

    125,585 pointsBadges:
    report
  • philpl1jb

    Agreed -- picked up the 4b 0 from another process.  I think we used  9b 0 before integer.types were introduced.

    D myInteger2 S 10i 0

    or for unsigned...

    D myInteger2 S 10u 0

    49,850 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following