|
|||||
operator |
- (negate)
|
Syntax
(- | negate) numeric-expression
Use - to change the sign of any numeric-expression. If the numeric-expression is positive, then the result is negative. If applied to a negative expression, the value becomes positive.
You use - as a unary operator (an operator with only one argument), to reverse the sign of a numeric expression.
Note: There should not be a space between the unary - and its argument:
If you negate the value of a BCD number, you must have imported "ombcd.xmd" in your program. If you negate the value of a floating point number, you must have import "omfloat.xmd" in your program. For BCD and floating point numbers, overflow and underflow values will return infinity and zero, respectively.
process local integer foo initial {9} local integer bar initial {7} output "Calculating ' - (9 + -7)' = " || "d" % - (foo + -bar) || "%n" ; displays "Calculating ' - (9 + -7)' = -2"
This does not change the absolute value of the numeric-expression.
Use the punctuative form ( - ) rather than the keyword negate
.
Usage examples:
-432 -("4987" + 315 * 12) - "3" > "04" negate "3" > "04"
BCD example:
import "ombcd.xmd" unprefixed process local bcd foo initial {23} local bcd bar set bar to -foo output "foo = " || "d" % foo || "%n" output "bar = " || "d" % bar || "%n" ; Output: foo = 23 ; bar = -23