Format

sign(A)

Returns

1 if A > 0, -1 if A < 0, 0 if A == 0

Args

A: A number or a vector.

Returns the sign of A. If used with a vector, a new vector is returned where sign() has been applied to each component.

usr << sign(20) // outputs 1
usr << sign(0)  // outputs 0
usr << sign(-3) // outputs -1

See also