Menu

Binary-Long

2024-12-23
2025-02-04
  • Ralph Linkletter

    Not being a "C" programmer I need a translation of Binary-Long to real COBOL.
    I am using an x86 machine.
    The PG has 300+ references to "binary-long"
    I could not find a translation in the PG.

    Thanks
    Ralph

     
    • Anonymous

      Anonymous - 2024-12-24

      The attached GnuCOBOL program can be used to determine sizes for various data types.

       
      • Ralph Linkletter

        I speculate that all on the "BINARY" data fields are little endian - correct ?
        So from what can discern BINARY-LONG would be in COBOL PIC 9(08) COMP-5.
        Yes ?

         
        • Simon Sobisch

          Simon Sobisch - 2024-12-24

          They are "native", so on x86 little-endian.
          I'd have to recheck but think that SIGNED is the default, so that would make it S9(9) COMP-5.

           
        • Vincent (Bryan) Coen

          Binary for is subject to the CPU you are using so it can be Big or small.
          Bin-long hold 4 bytes in a X64 CPU.

          On 24/12/2024 02:19, Ralph Linkletter wrote:

          I speculate that all on the "BINARY" data fields are little endian -
          correct ?
          So from what can discern BINARY-LONG would be in COBOL PIC 9(08) COMP-5.
          Yes ?

           
    • Mickey White

      Mickey White - 2024-12-24

      From what I see, binary-long is the same as comp-x and is 4 bytes in gnucobol 32 or 64 bit.

       
  • Arnold Trembley

    Arnold Trembley - 2024-12-24

    I missed my sign-in.

    The "usagelen.COB" program will show the lengths of various data types.

     
  • Mickey White

    Mickey White - 2024-12-24
           IDENTIFICATION DIVISION.
           PROGRAM-ID. Usage-Lengths01.
           environment division.
           configuration section.
           source-computer.
               System76
          *           with debugging mode
               .
           repository.
               function all intrinsic.
    
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01 Len-BINARY-C-LONG CONSTANT AS LENGTH OF BINARY-C-LONG.
           01 Len-BINARY-CHAR CONSTANT AS LENGTH OF BINARY-CHAR.
           01 Len-BINARY-DOUBLE CONSTANT AS LENGTH OF BINARY-DOUBLE.
           01 Len-BINARY-LONG CONSTANT AS LENGTH OF BINARY-LONG.
           01 Len-BINARY-SHORT CONSTANT AS LENGTH OF BINARY-SHORT.
           01 Len-COMP-1 CONSTANT AS LENGTH OF COMP-1.
           01 Len-COMP-2 CONSTANT AS LENGTH OF COMP-2.
           01 Len-FLOAT-DECIMAL-16 CONSTANT AS LENGTH OF FLOAT-DECIMAL-16.
           01 Len-FLOAT-DECIMAL-34 CONSTANT AS LENGTH OF FLOAT-DECIMAL-34.
           01 Len-FLOAT-LONG CONSTANT AS LENGTH OF FLOAT-LONG.
           01 Len-FLOAT-SHORT CONSTANT AS LENGTH OF FLOAT-SHORT.
           01 Len-POINTER CONSTANT AS LENGTH OF POINTER.
           01 Len-PROGRAM-POINTER CONSTANT AS LENGTH OF PROGRAM-POINTER.
           01 testx comp-15.
           01 testf34   float-decimal-34.
           01 testfl    float-long.
           01 testbd binary-double.
           01 testbcl binary-c-long.
           01 big38 comp-3 pic s9(36)v99.
           01 big9  pic  9(36).
           01 bigs9 pic  s9(36).
           01 binlong  binary-long.
           PROCEDURE DIVISION.
           000-Main.
           move -123456789012345678901234567890123456.78 to big38
           display "big38 = " big38
           DISPLAY "On this system, with this build of GnuCOBOL, the"
           DISPLAY "PICTURE-less USAGE’s have these lengths (in bytes):"
           DISPLAY " "
           DISPLAY "BINARY-C-LONG: " Len-BINARY-C-LONG
           DISPLAY "BINARY-CHAR: " Len-BINARY-CHAR
           DISPLAY "BINARY-DOUBLE: " Len-BINARY-DOUBLE
           DISPLAY "BINARY-LONG: " Len-BINARY-LONG
           DISPLAY "BINARY-SHORT: " Len-BINARY-SHORT
           DISPLAY "COMP-1: " Len-COMP-1
           DISPLAY "COMP-2: " Len-COMP-2
           DISPLAY "FLOAT-DECIMAL-16: " Len-FLOAT-DECIMAL-16
           DISPLAY "FLOAT-DECIMAL-34: " Len-FLOAT-DECIMAL-34
           DISPLAY "FLOAT-LONG: " Len-FLOAT-LONG
           DISPLAY "FLOAT-SHORT: " Len-FLOAT-SHORT
           DISPLAY "POINTER: " Len-POINTER
           DISPLAY "PROGRAM-POINTER: " Len-PROGRAM-POINTER
           display "test x com-15: " testx
               move PI to testx
           display "test x com-15: " testx
           move PI to testf34
           display testf34
           move PI to testfl
           display testfl
           move PI to testbd
           display testbd
           move PI to testbcl
           display testbcl
               compute testf34 = (PI * 10000000000000000000)
           display testf34
               compute testx = (PI / 1000000000000000000000000000000000000)
           display testx
    
           display 'test binary-long'
           move 2147483647 to binlong
           display 'binlong = ' binlong
           move binlong to big9
           display 'big9 = ' big9
           move binlong to bigs9
           display 'bigs9 = ' bigs9
    
    
           move -2147483647 to binlong
           display 'binlong = ' binlong
           move binlong to big9
           display 'big9 = ' big9
           move binlong to bigs9
           display 'bigs9 = ' bigs9
    
           move  4294967295 to binlong
           display 'binlong = ' binlong
           move binlong to big9
           display 'big9 = ' big9
           move binlong to bigs9
           display 'bigs9 = ' bigs9
    
           move  -4294967295 to binlong
           display 'binlong = ' binlong
           move binlong to big9
           display 'big9 = ' big9
           move binlong to bigs9
           display 'bigs9 = ' bigs9
    
    
    
    
           goback
           .
    

    resulting in

    big38 = -123456789012345678901234567890123456.78
    On this system, with this build of GnuCOBOL, the
    PICTURE-less USAGEΓÇÖs have these lengths (in bytes):
    
    BINARY-C-LONG: 4
    BINARY-CHAR: 1
    BINARY-DOUBLE: 8
    BINARY-LONG: 4
    BINARY-SHORT: 2
    COMP-1: 4
    COMP-2: 8
    FLOAT-DECIMAL-16: 8
    FLOAT-DECIMAL-34: 16
    FLOAT-LONG: 8
    FLOAT-SHORT: 4
    POINTER: 8
    PROGRAM-POINTER: 8
    test x com-15: 0
    test x com-15: 3.141592653589793
    3.141592653589793238462643383279502
    3.141592653589793
    +00000000000000000003
    +0000000003
    31415926535897932384.62643383279502
    3.141592653589793E-36
    test binary-long
    binlong = +2147483647
    big9 = 000000000000000000000000002147483647
    bigs9 = +000000000000000000000000002147483647
    binlong = -2147483647
    big9 = 000000000000000000000000002147483647
    bigs9 = -000000000000000000000000002147483647
    binlong = -0000000001
    big9 = 000000000000000000000000000000000001
    bigs9 = -000000000000000000000000000000000001
    binlong = +0000000001
    big9 = 000000000000000000000000000000000001
    bigs9 = +000000000000000000000000000000000001
    
     

    Last edit: Simon Sobisch 2025-02-04

Anonymous
Anonymous

Add attachments
Cancel





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.