The sign condition determines whether the algebraic value of a numeric operand is greater than, less than, or equal to zero.
operand-1 IS [NOT] {POSITIVE/NEGATIVE/ZERO} |
Program to demonstrate sign condition
IDENTIFICATION DIVISION. PROGRAM-ID. SIGCCOBL. DATA DIVISION. WORKING-STORAGE SECTION. 01 N1 PIC S9(9) VALUE -678. 01 N2 PIC S9(9) VALUE 78923. PROCEDURE DIVISION. A000-FIRST-PARA. IF N1 IS POSITIVE THEN DISPLAY 'NUMBER-1 IS POSITIVE'. IF N1 IS NEGATIVE THEN DISPLAY 'NUMBER-1 IS NEGATIVE'. IF N1 IS ZERO THEN DISPLAY 'NUMBER-1 IS ZERO'. IF N2 IS NEGATIVE THEN DISPLAY 'NUMBER-2 IS NEGATIVE'. IF N2 IS POSITIVE THEN DISPLAY 'NUMBER-2 IS POSITIVE'. STOP RUN. |
NUMBER-1 IS NEGATIVE NUMBER-2 IS POSITIVE |
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!