main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
948 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var GetIntrinsic = require('get-intrinsic');
|
---|
4 |
|
---|
5 | var $BigInt = GetIntrinsic('%BigInt%', true);
|
---|
6 | var $pow = GetIntrinsic('%Math.pow%');
|
---|
7 |
|
---|
8 | var ToBigInt = require('./ToBigInt');
|
---|
9 | var BigIntRemainder = require('./BigInt/remainder');
|
---|
10 |
|
---|
11 | var modBigInt = require('../helpers/modBigInt');
|
---|
12 |
|
---|
13 | // BigInt(2**63), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER
|
---|
14 | var twoSixtyThree = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 31)));
|
---|
15 |
|
---|
16 | // BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER
|
---|
17 | var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32)));
|
---|
18 |
|
---|
19 | // https://262.ecma-international.org/11.0/#sec-tobigint64
|
---|
20 |
|
---|
21 | module.exports = function ToBigInt64(argument) {
|
---|
22 | var n = ToBigInt(argument);
|
---|
23 | var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour);
|
---|
24 | return int64bit >= twoSixtyThree ? int64bit - twoSixtyFour : int64bit;
|
---|
25 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.