Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
700 bytes
|
Line | |
---|
1 | var $ = require('../internals/export');
|
---|
2 | var fails = require('../internals/fails');
|
---|
3 |
|
---|
4 | // eslint-disable-next-line es/no-math-imul -- required for testing
|
---|
5 | var $imul = Math.imul;
|
---|
6 |
|
---|
7 | var FORCED = fails(function () {
|
---|
8 | return $imul(0xFFFFFFFF, 5) != -5 || $imul.length != 2;
|
---|
9 | });
|
---|
10 |
|
---|
11 | // `Math.imul` method
|
---|
12 | // https://tc39.es/ecma262/#sec-math.imul
|
---|
13 | // some WebKit versions fails with big numbers, some has wrong arity
|
---|
14 | $({ target: 'Math', stat: true, forced: FORCED }, {
|
---|
15 | imul: function imul(x, y) {
|
---|
16 | var UINT16 = 0xFFFF;
|
---|
17 | var xn = +x;
|
---|
18 | var yn = +y;
|
---|
19 | var xl = UINT16 & xn;
|
---|
20 | var yl = UINT16 & yn;
|
---|
21 | return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
|
---|
22 | }
|
---|
23 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.