>>SOURCE FORMAT IS FREE *> cobol-move-binary-truncate.cob - the MOVE lesson's probe for what *> changes between dialects: MOVEs into COMP, COMP-5 and DISPLAY *> receivers that are too small for the value, a negative value into *> unsigned binary, and how DISPLAY shows a signed and a decimal item *> Dialect: GnuCOBOL 3.x, free format; meant to be compiled once per *> dialect (the lesson shows default, -std=ibm and -std=mf): *> cobc -x cobol-move-binary-truncate.cob *> cobc -x -std=ibm cobol-move-binary-truncate.cob *> cobc -x -std=mf cobol-move-binary-truncate.cob *> Status : compiled and run with GnuCOBOL 3.2 on 2026-10-30 *> Inputs : none *> Outputs: eight lines on standard output *> Run : ./cobol-move-binary-truncate *> (Windows: cobol-move-binary-truncate.exe) IDENTIFICATION DIVISION. PROGRAM-ID. MOVE-BINARY. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-Big PIC 9(5) VALUE 12345. 01 WS-Neg PIC S9(5) VALUE -42. 01 WS-Disp-3 PIC 9(3). 01 WS-Comp-3dig PIC 9(3) COMP. 01 WS-Comp5-3dig PIC 9(3) COMP-5. 01 WS-Comp-4dig PIC 9(4) COMP. 01 WS-Comp-Unsigned PIC 9(3) COMP. 01 WS-Signed PIC S9(3). 01 WS-Money PIC 9(3)V99 VALUE 123.45. 01 WS-Bytes PIC 9(2). 01 WS-Stored PIC 9(5). PROCEDURE DIVISION. MAIN-PARAGRAPH. *> A. The same five-digit value into four three- and four-digit items. MOVE WS-Big TO WS-Disp-3 MOVE WS-Big TO WS-Comp-3dig MOVE WS-Big TO WS-Comp5-3dig MOVE WS-Big TO WS-Comp-4dig *> Each line shows the item as DISPLAY prints it, then the value it *> holds, copied into a five-digit DISPLAY item so that the second *> column does not depend on how DISPLAY formats binary items. MOVE WS-Disp-3 TO WS-Stored DISPLAY "A 12345 to 9(3) DISPLAY : " WS-Disp-3 " holds " WS-Stored MOVE WS-Comp-3dig TO WS-Stored DISPLAY "A 12345 to 9(3) COMP : " WS-Comp-3dig " holds " WS-Stored MOVE WS-Comp5-3dig TO WS-Stored DISPLAY "A 12345 to 9(3) COMP-5 : " WS-Comp5-3dig " holds " WS-Stored MOVE WS-Comp-4dig TO WS-Stored DISPLAY "A 12345 to 9(4) COMP : " WS-Comp-4dig " holds " WS-Stored *> B. A negative value into unsigned binary: the sign is still dropped. MOVE WS-Neg TO WS-Comp-Unsigned DISPLAY "B -42 to 9(3) COMP : " WS-Comp-Unsigned *> C. How DISPLAY shows a signed item and an item with an implied point. MOVE WS-Neg TO WS-Signed DISPLAY "C -42 in S9(3) : " WS-Signed DISPLAY "C 123.45 in 9(3)V99 : " WS-Money *> D. How many bytes the three-digit COMP item takes. MOVE FUNCTION BYTE-LENGTH (WS-Comp-3dig) TO WS-Bytes DISPLAY "D bytes in 9(3) COMP : " WS-Bytes STOP RUN.