Hello,
I have found a failure in the Class Condition test for IF NUMERIC.
Low-Values are being accepted as valid data. Both IBM and Micro Focus
document that the valid range for a numeric is 0-9 (with or without an
operational sign).
I also tested High-Values and it is flagged as invalid. So it seems
only Low-Values are being allowed invalidly.
I am including 3 test programs, but you need to only look at lovalues.cbl.
Thanks, Vince
when I compile and run "lovalues.cbl", I do not see any error.
Last edit: Arnold Trembley 2024-04-24
Hello Arnold, Look at the DISPLAY output. GnuCobol says Low-Values are Zero.
MF takes both False paths and says Low-Values are Not Zero. Look as lovalues.jpg for side by side compares. Thanks, Vince
! Sorry. IF NUMERIC does state it is invalid. Compare to Zero fails. I was checking various condition in the same program.
WS1A has picture 9(5) usage DISPLAY, but contains non-numeric data X'0000000000'.
If you compare WS1A to zero, what result would you expect?
A. WS1A equals zero
B. WS1A is NOT equal to zero
C. Program terminates abnormally for WS1A contains invalid non-numeric data
D. Something else?
Apparently Microfocus COBOL chooses B and GnuCOBOL chooses A. I believe certain older IBM mainframe COBOL compilers also chose A (due to S/360 instruction set).
I no longer have access to an IBM Enterprise COBOL compiler for z/OS, so I don't know what IBM's current COBOL compiler would do in this situation. But I know many IBM COBOL applications programmers who are capable of coding applications to prevent problems with invalid data like this.
Kind regards,
From what I see:
DISPLAYdata is noted asNOT NUMERIC-fec=all, or--debugZEROand ASCII and EBCDICSPACEare handled as zeroI don't see a bug here. Did I miss something?
Hello, So x'00' and x'20' are taken as x'30' (ASCII or ANSI) since only the right-most half-byte value is used. The mainframe also has this behavior. That explains what is happening. The reason why IBM did that is because the underlying Assembler code used a PACK and UNPK for decimal conversion. Those operations ignored the first half of the numeric byte and so it allowed for a SPACE or LOW-VALUE to be used as a Zero. Thank You! Please close this as a non-bug. Vince