Closed username1565 closed 3 years ago
The problem is that you should put the number inside a string, like this:
console.log(new bigInt("1005000000000000000000000").toString()); //---> "1005000000000000000000000"
This is because 1005000000000000000000000 is too large to preserve precision as a native JavaScript number.
@peterolson, Look at this:
new bigInt('1005010000000000000000').prev().toString('1005010000000000000000') //"<1.00501e+21>"
P.S.: function toBase()
, contains .toJSNumber()
, so large values is invalid and are exponential:
//MAX_INT = 9007199254740992,
//MAX_INT = Number.MAX_SAFE_INTEGER, //= 9007199254740991
//...
if (base.toJSNumber() > MAX_INT) {
throw new Error("Base too high: (base.toJSNumber() > MAX_INT): "+(base.toJSNumber() > MAX_INT)+'. Maximum is: '+MAX_INT);
}
By design bases that are too large are not supported.
Ok. Look at this https://github.com/peterolson/BigInteger.js/blob/2c922709216d64b499bee1eda3172c3bb1b8fca8/BigInteger.js#L1192
this always true, because:
var x = undefined;
console.log(!x); //true;
so
(ceseSencetive !== undefined && !caseSencetive)
or just (caseSencetive==!1)
will works, there.
or
(
caseSensitive !== undefined //if defined, because (!undefined === true)
&& !caseSensitive //and if not sencetive for the case
&& (new Set(alphabet.toLowerCase()).size === alphabet.length) //and if all lower-cased characters are unique
)
Also, you can look on my changes, in the file BigInteger.js
, at your free time:
https://github.com/peterolson/BigInteger.js/compare/master...username1565:master
Hello. I see you added the supporting for NativeBigInt. I want to say, you, this is supporting
.toString()
method,and old bigInt object was working good.
To return a native BigInt, there is enough to make
Maybe, you can minify bigint library, using this.
Also, I see a some bug, and maybe, you can fix it:
Best regards.