web 3d图形渲染器
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.

17 lines
400 B

  1. "use strict";
  2. var exp = Math.exp;
  3. module.exports = function (value) {
  4. var num1, num2;
  5. if (isNaN(value)) return NaN;
  6. value = Number(value);
  7. if (value === 0) return value;
  8. if (value === Infinity) return 1;
  9. if (value === -Infinity) return -1;
  10. num1 = exp(value);
  11. if (num1 === Infinity) return 1;
  12. num2 = exp(-value);
  13. if (num2 === Infinity) return -1;
  14. return (num1 - num2) / (num1 + num2);
  15. };