esnext.math.umulh.js 515 B

123456789101112131415161718
  1. var $ = require('../internals/export');
  2. // `Math.umulh` method
  3. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  4. // TODO: Remove from `core-js@4`
  5. $({ target: 'Math', stat: true }, {
  6. umulh: function umulh(u, v) {
  7. var UINT16 = 0xFFFF;
  8. var $u = +u;
  9. var $v = +v;
  10. var u0 = $u & UINT16;
  11. var v0 = $v & UINT16;
  12. var u1 = $u >>> 16;
  13. var v1 = $v >>> 16;
  14. var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
  15. return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);
  16. }
  17. });