Unary Arithmetic OperatorsΒΆ

Material prepared from M Programming Book [WALTERS1997]

Page 47

Unary operators are the + and - arithmatic operators if they appear in front of a single operand. Using Unary Operators, strings can be converted to numerical values. The unary “plus” sign does not change the string (It returns the numeric value of the string), the negative unary sign, “minus” changes the sign of the value.

Example:

SET A=0
SET B=1
SET C=-1

WRITE +A returns 0
WRITE -A returns 0
WRITE +B returns 1
WRITE -B returns -1
WRITE +C returns -1
WRITE -C returns 1