Menu

Correct usage of binary-long, binary-short and binary-int

GnuCOBOL
2020-11-06
2020-11-07
  • Gerald Chudyk

    Gerald Chudyk - 2020-11-06

    Hi everyone,

    In the distant past I used the GnuCOBOL binary-long to represent a C code int. Recently reading the great GnuCOBOL docs late at night, I came across a table that used binary-short. I thought 'Oh well' and tried it on a very superficial test and it worked ok. In the light of day a binary-long still looks right to my 64 bit mind. Looking into other things today, I found the binary-int in use in some sample code and thought that would be the best representation to use.

    I realize this stuff has been evolving over the almost 10 years that I have been away and that I should take care to use the language correctly. Is binary-int the better choice?

    Thanks,
    Gerald.

     
  • Simon Sobisch

    Simon Sobisch - 2020-11-06

    That completely depends on what you want.

    • binary-short is a 16-bit integer, and possibly not what you look for
    • binary-long is a 32-bit integer; binary-int is identical, but an extension so I'd rather not use it (and if you then get to a compiler that does not understand the standard version either make it an alias or use a global REPLACE command)
    • binary-double is a 64-bit integer

    If you ever CALL into C space you should use whatever the C functions want, with taking the machine / architecture / c-library into account.

     
  • Gerald Chudyk

    Gerald Chudyk - 2020-11-06

    Thank you Simon.

     
  • Vincent (Bryan) Coen

    If you look at the PG (Programmer Guide) manual at section 6.8.1 for a list of all with their byte sizes at the end of this section and at 6.9.49 for USAGE BINARY for all of the differenrt types and their max values for signed and unsigned values it might help you.

    There are other sources for development notes which I must get around to put them all together as GC Programmer Briefs / Notes .

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.