- Unary negative operator

Reverses the sign of a numeric expression. Do not confuse this operator with the subtraction operator that subtracts one expression from another.

Syntax

- expression
expression
An expression whose value is numeric.

Example

If you supply a negative value for the variable fx, the r-uneg.p procedure uses the unary negative operator (-) to reverse the sign of fx, producing the absolute value of fx (fabs-x).

r-uneg.p

DEFINE VARIABLE fx     AS DECIMAL NO-UNDO LABEL "X".
DEFINE VARIABLE fabs-x AS DECIMAL NO-UNDO LABEL "ABS(X)".

REPEAT:
  SET fx.
  IF fx < 0 THEN
   fabs-x = -fx.
  ELSE 
    fabs-x = fx.
  DISPLAY fabs-x.
END.

See also

+ Unary positive operator