I got curious result for the following COBOL substract statement:
WS-SUB2 PIC S9 COMP VALUE ZEROS.
WS-START PIC 9(2) VALUE ZEROES.
WS-END PIC 9(2) VALUE ZEROES.
WS-DIFF PIC 9(2) VALUE ZEROES.
::::::::::::::::::::::::::::::::::::::::::::::::::::::
SUBTRACT WS-START FROM WS-SUB2 GIVING WS-DIFF
:::::::::::::::::::::::::::::::::::::::::::::::::::::
when ws-sub2 = +0015 ws-start = 09 the WS-DIFF is 04 instead of 6;
when ws-sub2 = +0016 ws-start = 09 the WS-DIFF is 03 instead of 7;
when ws-sub2 = +0017 ws-start = 09 the WS-DIFF is 02 instead of 8;
when ws-sub2 = +0018 ws-start = 09 the WS-DIFF is 01 instead of 9;
when ws-sub2 = +0019 ws-start = 09 the WS-DIFF is 00 instead of 10;
when ws-sub2 = +0020 ws-start = 09 the WS-DIFF is 09 instead of 11;
when ws-sub2 = +0021 ws-start = 09 the WS-DIFF is 08 instead of 12;
when ws-sub2 = +0022 ws-start = 09 the WS-DIFF is 07 instead of 13;
I dout mybe the datatype caused the issue, could you tell me what's wrong?
thanks for your help,
Helen