We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 817a7e0 commit da1866dCopy full SHA for da1866d
Maths/Signum.js
@@ -12,13 +12,14 @@
12
13
/**
14
* @param {Number} input
15
- * @returns {-1 | 0 | 1 | NaN} sign of input (and NaN if the input is NaN)
+ * @returns {-1 | 0 | 1 | NaN} sign of input (and NaN if the input is not a number)
16
*/
17
function signum (input) {
18
- if (isNaN(input)) return NaN
19
- else if (input === 0) return 0
+ if (input === 0) return 0
+ else if (input > 0) return 1
20
else if (input < 0) return -1
21
- else return 1
+
22
+ return NaN
23
}
24
25
export { signum }
0 commit comments