Functions

sgn

Supported By

Syntax

[the] sgn of factor

sgn ( expression )

Factor and expression yield integers, numbers, or complexes.

Description

If its argument is an integer or a number, the sgn function returns -1 if the specified numeric value is negative, 1 if the specified numeric value is positive, 0 if the specified numeric value is zero, and NaN if the specified numeric value is NaN.

If its argument is a complex, the sgn function returns a complex with the same complex argument but an absolute value of 1. For example, sgn(3,4) returns 0.6,0.8.

Note

For nonzero values of n, sgn(n) = n / abs(n).

Synonym

signum