Open Daniel15 opened 5 years ago
https://gist.github.com/CatsMiaow/7fc9f28c9d2a5ab6d7605646086fdca6 I created a sample code using bignumber.js
@CatsMiaow Modern browsers have a native BigInt type: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt :)
I know but BigInt doesn't work as I want.
console.log(616580508813361172); // 616580508813361200
BigInt(616580508813361172); // 616580508813361152n
616580508813361152n.toString(); // "616580508813361152"
BigInt(616580508813361172).toString(); // "616580508813361152"
BigInt(616580508813361172).toString() === "616580508813361172" // false
But as I wrote this comment, I checked again
BigInt("616580508813361172").toString() === "616580508813361172" // true
🤔
Rewritten with BigInt https://gist.github.com/CatsMiaow/b479e96d5613dbd4711ab6d768b3eea0
same issue here trying to encode this hex number: 5fce40b61ddd1a677bbdd9d7
back & forth get's it truncated into 5fce40b61ddd240000000000
With BigInt more common nowadays, it'd definitely be nice to have this functionality
Would be good to get BigInt support... I think the current version doesn't support BigInts.