SIGN [SIGNUM] inputVector resultVector

Copies the sign ("+" or "-") of each element of the input vector into the output vector. If an element in inputVector is negative, its corresponding element in resultVector will be -1.0. If an element in inputVector is positive or zero, its corresponding element in resultVector will be 1.0.

If the keyword signum is present, the zero elements in the input vector will become zeros in the output vector. This is the standard behavior of the mathematical signum() function.

Usage with the LET command

When used with the LET command, this command has two names. If you want the default behavior in a LET command, use the name SIGN. If you want the optional signum() behavior, use the name SIGN_SIGNUM. See examples at right.


Here is a simple example showing what the SIGN command does:

SIGN (1.234 -1.234 0 4 -5 6 -0) signs
PRINT signs

The above program produces the following output:

signs: (1.0 -1.0 1.0 1.0 -1.0 1.0 1.0)

If you add the signum keyword,

SIGN signum (1.234 -1.234 0 4 -5 6 -0) signs

you get this result:

signs: (1.0 -1.0 0.0 1.0 -1.0 1.0 0.0)

Behavior in LET command: 
LET A = SIGN(-1.2 0 1.3)
PRINT A

produces:

A: (-1.0 1.0 1.0)

But, 
LET A = SIGN_SIGNUM(-1.2 0 1.3)
PRINT A
produces:

A: (-1.0 0.0 1.0)