math-sign-x
ES6-compliant shim for Math.sign.
Requires ES3 or above.
See: 20.2.2.29 Math.sign(x)
Version: 1.2.0
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750
module.exports
⇒ number
⏏
This method returns the sign of a number, indicating whether the number is positive,
negative or zero.
Kind: Exported member
Returns: number
- A number representing the sign of the given argument. If the argument
is a positive number, negative number, positive zero or negative zero, the function will
return 1, -1, 0 or -0 respectively. Otherwise, NaN is returned.
Param | Type | Description |
---|
x | * | A number. |
Example
var mathSign = require('math-sign-x');
mathSign(3);
mathSign(-3);
mathSign('-3');
mathSign(0);
mathSign(-0);
mathSign(NaN);
mathSign('foo');
mathSign();