sign in
 
   
 
 
 
   
  COBOL TUTORIAL FOR BCA STUDENTS OF M G UNIVERSITY  
  UNIT 4: PROCEDURE DIVISION . . .  
   
 

SIGN CONDITION

 
   
 

The sign condition determines whether or not the algebraic value of an operand is positive, negative or zero. The operand can be either a numeric identifier or an arithmetic expression.

The format of this condition is as follows:

 
   
 

When arithmetic expression is used, it must contain at least one identifier. The POSITIVE option determines the value of the condition to be true only if the value of the operand strictly positive. This means that the value zero is not treated as positive.

Example:

 
  77 BALANCE PIC S9 (6) V99.
.
.
IF BALANCE IS ZERO GO TO NIL-BALANCE.
 
 

It may be noted that the above IF statement is equivalent to the following statement that makes use of a relational condition.

 
  IF BALANCE = 0 GO TO NIL-BALANCE.  
 

Example:

 
  02 DEPOSIT PIC 9(4) V99.
02 WITHDRAWAL PIC 9(4) V99.
.
.
.
IF DEPOSIT - WITHDRAWAL IS POSITIVE GO TO CALCULATION.
 
 

The control is transferred to the paragraph named CALCULATION if the current value
of DEPOSIT is greater than that of WITHDRAWAL.

In general, any sign condition can be replaced by an equivalent relational condition. The use of the sign condition may perhaps be convenient in certain cases and its use may also increase the readability of the statement that uses it.