Compute the signum function.
This is defined as
-1, x < 0; sign (x) = 0, x = 0; 1, x > 0.
For complex arguments, sign
returns x ./ abs (x)
.
Note that sign (-0.0)
is 0. Although IEEE 754 floating point
allows zero to be signed, 0.0 and -0.0 compare equal. If you must test
whether zero is signed, use the signbit
function.
See also: signbit.
Package: octave