mercredi 11 avril 2018

Cobol - checking for remainder in IF clause

I am wondering if there is any method to check the remainder of division in IF statement like: if (16 % 2 == 0) {...}

So far I have this:

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 number-in pic 9(3).
   01 number-out pic Z9.
   01 result pic 9.
   01 residue pic 9.
   PROCEDURE DIVISION.
   MAIN-PROCEDURE.

       MOVE 4 TO number-in.
       PERFORM L1-LOOP UNTIL number-in = 100.
       STOP RUN.

       L1-LOOP.
           DIVIDE number-in BY 2 GIVING result REMAINDER residue.
           IF residue = 0
               MOVE number-in to number-out
               DISPLAY number-out.
           ADD 1 TO number-in.

But here I have to use additional variable (result) to get remainder (residue) of the division. I would like to avoid this and check the remainder directly in the IF statement. Is it possible in Cobol? I would be grateful for some information or link.

Aucun commentaire:

Enregistrer un commentaire