Menu

PICTURE 1

GnuCOBOL
2025-09-20
2025-09-20
  • Eugenio Di Lorenzo

    PG at Chapter 6.9.34 PICTURE, page 201 says:

    ‘1’ Defines storage for a single bit representing a boolean condition with a states of zero or
    1, condition of off or on. Warning the level of implementation of this feature is compiler
    version specific starting with v3.1-RC-1.

    However, using PICTURE 1, it behaves identically to PICTURE 9.
    See following sample program.
    Am I doing something wrong ?

             >>SOURCE FREE
    IDENTIFICATION DIVISION.
    PROGRAM-ID. TESTPICTURE.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 wBIT02 PIC 1(6).
    PROCEDURE DIVISION.
        move 109870 to wBIT02
        display wBIT02 ' ' function HEX-OF(wBIT02)
        accept omitted
        STOP RUN.
    
     
  • Simon Sobisch

    Simon Sobisch - 2025-09-20

    No (other than the bad move, which is not checked yet, and the unexpected result because of bit fields are not handled specially for DISPLAY (which may be relative easy to do....).
    code-wise: you should MOVE b'00011010110100101110' to wBIT02, which then should tell you, you have an overflow as you've only have 6 bits available (note: GC 3 will reserve up to the next 8 bytes in any case).

    .. but: you should get a warning that this is unfinished when compiling with -Wall.
    You do - don't you?

     

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.