f16.js 598 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.decodeF16 = void 0;
  4. const pow = Math.pow;
  5. const decodeF16 = (binary) => {
  6. const exponent = (binary & 0x7c00) >> 10;
  7. const fraction = binary & 0x03ff;
  8. return ((binary >> 15 ? -1 : 1) *
  9. (exponent
  10. ? exponent === 0x1f
  11. ? fraction
  12. ? NaN
  13. : Infinity
  14. : pow(2, exponent - 15) * (1 + fraction / 0x400)
  15. : 6.103515625e-5 * (fraction / 0x400)));
  16. };
  17. exports.decodeF16 = decodeF16;
  18. //# sourceMappingURL=f16.js.map