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