Skip to content

sign

Sign of a number.

Y = sign(X)

For real X, returns +1, 0, or -1 depending on sign. For complex X, returns X / abs(X) (a unit-magnitude complex number with the same direction). Returns 0 for X = 0.

sign(-5) % -1
sign(0) % 0
sign(3 + 4i) % 0.6 + 0.8i
  • abs — Absolute value.
  • real — Real part of a complex number.
  • imag — Imaginary part of a complex number.