Re: Why would COBOL act like this?





"Tom" <thasselb@xxxxxxxxx> wrote in message
news:1191632165.666985.110840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I had an issue surrounding the following COBOL statement. We use LE
COBOL on z/OS.
IF PCT> 0

When the value of PCT, which is defined as PIC 9.99, was 0.00, the
0.00 was greater than 0. This surprised me; I thought a numeric 0.00
should be the same as a numeric 0.

I tried to change the offending statement to
IF PCT> 0.00.
COBOL didn't like that. I got a compile error.

My next approach was to define a constant like so:
05 C-ZERO PIC 9.99 VALUE 0.
COBOL hated that. Another compile error.

My next approach was to define the constant like so:
05 C-ZERO PIC 9.99 VALUE ZERO.
That compiled OK, but the value of C-ZERO was 0000, and I was looking
for 0.00.

The final attempt worked like a charm:
05 W-ZERO PIC 9.99.
MOVE 0 TO W-ZERO
IF PCT > W-ZERO

All of these findings surprised me. I was disappointed that I had to
define a variable and initialize it to zero in the procedure division.

You don't have to do that, Tom. You are missing the difference between a .
in a picture and a V in a picture.

pic 99.9 is an edited string
pic 99v9 is considered to be a decimal number with one implied decimal
place.

Check your manual on the PICTURE clause use of V and . for examples.

Pete.
--
"I used to write COBOL...now I can do anything."



.



Relevant Pages

  • Re: Why would COBOL act like this?
    ... IF PCT> 0.00. ... COBOL didn't like that. ... 05 W-ZERO PIC 9.99. ... in a picture and a V in a picture. ...
    (comp.lang.cobol)
  • Why would COBOL act like this?
    ... I had an issue surrounding the following COBOL statement. ... When the value of PCT, which is defined as PIC 9.99, was 0.00, the ... 05 W-ZERO PIC 9.99. ...
    (comp.lang.cobol)
  • Re: Why would COBOL act like this?
    ... COBOL), I thought I would give you a few online references - but first, let me ... alphanumeric if they are USAGE DISPLAY and national if USAGE NATIONAL. ... If PCT> "0.00" ...
    (comp.lang.cobol)
  • Re: Why would COBOL act like this?
    ... IF PCT> 0.00. ... COBOL didn't like that. ... I got a compile error. ... 05 C-ZERO PIC 9.99 VALUE ZERO. ...
    (comp.lang.cobol)