es6.math.imul.js 539 B

1234567891011121314151617
  1. // 20.2.2.18 Math.imul(x, y)
  2. var $export = require('./_export');
  3. var $imul = Math.imul;
  4. // some WebKit versions fails with big numbers, some has wrong arity
  5. $export($export.S + $export.F * require('./_fails')(function () {
  6. return $imul(0xffffffff, 5) != -5 || $imul.length != 2;
  7. }), 'Math', {
  8. imul: function imul(x, y) {
  9. var UINT16 = 0xffff;
  10. var xn = +x;
  11. var yn = +y;
  12. var xl = UINT16 & xn;
  13. var yl = UINT16 & yn;
  14. return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
  15. }
  16. });