mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-23 16:13:18 +00:00
23 lines
654 B
JavaScript
23 lines
654 B
JavaScript
|
var $ = require('../internals/export');
|
||
|
var fails = require('../internals/fails');
|
||
|
|
||
|
var nativeImul = Math.imul;
|
||
|
|
||
|
var FORCED = fails(function () {
|
||
|
return nativeImul(0xFFFFFFFF, 5) != -5 || nativeImul.length != 2;
|
||
|
});
|
||
|
|
||
|
// `Math.imul` method
|
||
|
// https://tc39.github.io/ecma262/#sec-math.imul
|
||
|
// some WebKit versions fails with big numbers, some has wrong arity
|
||
|
$({ target: 'Math', stat: true, forced: FORCED }, {
|
||
|
imul: function imul(x, y) {
|
||
|
var UINT16 = 0xFFFF;
|
||
|
var xn = +x;
|
||
|
var yn = +y;
|
||
|
var xl = UINT16 & xn;
|
||
|
var yl = UINT16 & yn;
|
||
|
return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
|
||
|
}
|
||
|
});
|