signum ( x -- y ) (original) (raw)

signum ( x -- y )

Vocabulary
math.functions

Inputs

x a number

Outputs

y a number

Word description
Calculates the signum value. For a real number, x, this is its sign (-1, 0, or 1). For a complex number, x, this is the point on the unit circle of the complex plane that is nearest to x.

Definition

IN: math.functions

GENERIC: signum ( x -- y )

Methods

USING: kernel math math.functions ;

M: complex signum dup abs / ;

USING: math math.functions ;

M: real signum sgn ;