Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

signum

mikolalysenko597.9kMIT1.0.0

Returns the sign of a number

sign, number, signum, plus, minus, zero

readme

signum

Returns the sign of a floating point number

Example

var sgn = require("signum")

console.log(sgn(-0.00001))
console.log(sng(0))
console.log(sng(Infinity))

Output:

-1
0
1

Install

npm install signum

API

require("signum")(x)

Returns the sign of x

  • x is a number

Returns One of the following values

  • -1 if x<0
  • 1 if x>0
  • 0 otherwise

Credits

(c) 2014 Mikola Lysenko. MIT License