Quantcast
Viewing latest article 1
Browse Latest Browse All 4

Answer by Bill Woodger for How to convert Decimal Values to Strings in COBOL

IDENTIFICATION DIVISION. PROGRAM-ID. EXAMPLE. DATA DIVISION. WORKING-STORAGE SECTION. 01  Y PIC X(15). 01  T REDEFINES Y PIC -(5)9(7).99.01  U REDEFINES Y PIC -9(7).99B(4).01  X PIC S9(7)V9(2). PROCEDURE DIVISION.     MOVE -1234567.89 TO X     MOVE X TO T     DISPLAY 'X: >' X '< Y: >' Y '<'    MOVE X TO U     DISPLAY 'X: >' X '< Y: >' Y '<'    GOBACK     . 

T gives right-alignment, U gives left-alignment. As both REDEFINES occupy the full 15 bytes, there is no need to take account of any value in Y prior to the MOVEs to T or U.

Output is:

X: >12345678R< Y: >    -1234567.89<X: >12345678R< Y: >-1234567.89    <

Viewing latest article 1
Browse Latest Browse All 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>