Returns the inverse sign of a number.
function returns the inverse sign of a number. For example, NEG
(-1) returns 1, and NEG
(1) returns -1. NEG
removes multiple signs and leading and trailing zeros from number
. A string is parsed as a number until a non-numeric character is encountered. Thus 7dwarves is parsed as 7. If number
is the empty string or a non-numeric value, NEG
returns 0 (zero).
function inverts the sign of a number: negative numbers become positive and positive numbers become negative. The ABS
function gives the absolute value of a number: all numbers become positive.
You can use the NEGS
function to invert the sign for each element of a dynamic array.
The following example uses the NEG
function to invert the sign of a number:
PRINT NEG(0050.300); ! Returns -50.3
PRINT NEG(-50.3); ! Returns 50.3
PRINT NEG(+++50.3); ! Returns -50.3
PRINT NEG(0); ! Returns 0
PRINT NEG(-0); ! Returns 0