peterolson / BigInteger.js

An arbitrary length integer library for Javascript
The Unlicense
1.12k stars 187 forks source link

Leading plus sign should be allowed when parsing #206

Open ghost opened 4 years ago

ghost commented 4 years ago

With native BigInt, BigInt('+10') parses correctly as 10. Unfortunately, using this library, bigInt('+abc', 16) does not correctly parse as 0xabc, even though bigInt('-abc', 16) parses correctly as -0xabc.

This leads to inconsistencies in parsing when the base is equal to 10 compared to other bases. Not sure if I'll have time to submit a PR, but will probably do so if no one gets to this in the next few days.

Yaffle commented 4 years ago

native BigInt does not allow BigInt('-0xabc')

ghost commented 4 years ago

No, but bigInt(string, 10) defers to BigInt(string) which does allow -10 and +10