You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
400 B
18 lines
400 B
"use strict";
|
|
|
|
var exp = Math.exp;
|
|
|
|
module.exports = function (value) {
|
|
var num1, num2;
|
|
if (isNaN(value)) return NaN;
|
|
value = Number(value);
|
|
if (value === 0) return value;
|
|
if (value === Infinity) return 1;
|
|
if (value === -Infinity) return -1;
|
|
num1 = exp(value);
|
|
if (num1 === Infinity) return 1;
|
|
num2 = exp(-value);
|
|
if (num2 === Infinity) return -1;
|
|
return (num1 - num2) / (num1 + num2);
|
|
};
|