1
0

shim.js 445 B

12345678910111213
  1. // Thanks: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
  2. // /Global_Objects/Math/imul
  3. 'use strict';
  4. module.exports = function (x, y) {
  5. var xh = (x >>> 16) & 0xffff, xl = x & 0xffff
  6. , yh = (y >>> 16) & 0xffff, yl = y & 0xffff;
  7. // the shift by 0 fixes the sign on the high part
  8. // the final |0 converts the unsigned value into a signed value
  9. return ((xl * yl) + (((xh * yl + xl * yh) << 16) >>> 0) | 0);
  10. };