/math/sign
stdCalculates the sign of the value and returns -1 for negative values, 1 for positive values and 0 for zeros.
Type signature
(x: number) => number
Examples
sign(3);
// ⇒ 1
Try in REPL
sign(-5);
// ⇒ 5
Try in REPL
sign(0);
// ⇒ 0
Try in REPL
sign(-0);
// ⇒ 0
Try in REPL
Questions
- How to get a sign of a number?