Display wrong format in micro focus visual cobol.

Hi.

Recently, i code a test program as below :

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TEST PIC 9(5)V9(2) VALUE 13.5.
01 WS-NUM3 PIC S9(3)V9(2) VALUE -123.45.

PROCEDURE DIVISION.
DISPLAY WS-TEST.
DISPLAY WS-NUM3.
STOP RUN.

When i run by ctrl f11 then the result in console command is :

0001350
12345-

But when i run this project on OpenCobolIDE then result is correct : 

00013.50

-123.45

Plz help me.

Parents
  • Verified Answer

    You can do the following:

          01  WS-TEST   pic 9(5)v9(2) value 13.5.

          01  WS-NUM3   pic S9(3)V9(2) VALUE -123.45.

          01  WS-TEST-2 pic 9(5).9(2) value 13.5.

          01  WS-NUM3-2 pic ---9.9(2) VALUE -123.45.

              display WS-TEST.

              display WS-NUM3.

              display WS-TEST-2

              display WS-NUM3-2.

    Results would be:

    0001350  

    12345-  

    00013.50

    -123.45  

    Or you can write:

          01  WS-TEST   pic 9(5)v9(2) value 13.5.

          01  WS-NUM3   pic S9(3)V9(2) VALUE -123.45.

          01  WS-TEST-2 pic 9(5).9(2).

          01  WS-NUM3-2 pic ---9.9(2).

              move ws-test to ws-test-2.

              move ws-num3 to ws-num3-2.

              display ws-test-2.

              display ws-num3-2.

    Results would be:

    00013.50

    -123.45  

Reply
  • Verified Answer

    You can do the following:

          01  WS-TEST   pic 9(5)v9(2) value 13.5.

          01  WS-NUM3   pic S9(3)V9(2) VALUE -123.45.

          01  WS-TEST-2 pic 9(5).9(2) value 13.5.

          01  WS-NUM3-2 pic ---9.9(2) VALUE -123.45.

              display WS-TEST.

              display WS-NUM3.

              display WS-TEST-2

              display WS-NUM3-2.

    Results would be:

    0001350  

    12345-  

    00013.50

    -123.45  

    Or you can write:

          01  WS-TEST   pic 9(5)v9(2) value 13.5.

          01  WS-NUM3   pic S9(3)V9(2) VALUE -123.45.

          01  WS-TEST-2 pic 9(5).9(2).

          01  WS-NUM3-2 pic ---9.9(2).

              move ws-test to ws-test-2.

              move ws-num3 to ws-num3-2.

              display ws-test-2.

              display ws-num3-2.

    Results would be:

    00013.50

    -123.45  

Children
No Data