Why doesn't BigNumber.toString allow an arbitrary base?
See original GitHub issueHello, I’m getting this error when using @ethersproject/bignumber
bigNumber.toString does not accept parameters (code=UNEXPECTED_ARGUMENT, version=bignumber/5.0.1)
It’s coming from this toString()
override where the comment indicates this is intentionally not supported:
https://github.com/ethers-io/ethers.js/blob/d817416bae2fbc7adb8391fd038613241b7ab8ba/packages/bignumber/src.ts/bignumber.ts#L186
I’m wondering why is this not supported.
On the surface it looks like ethers could pipe the base
and padding
parameters to the underlying BN implementation, like so:
toString(base: any, padding: any): string {
return toBN(this).toString(base || 10, padding);
}
What am I missing?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
React: Please pass numbers as strings or BigNumber objects ...
The first way throws the error 'Unhandled Rejection (TypeError): Cannot read property 'toString' of undefined' - why is that? And the second one ......
Read more >bignumber.js API - GitHub Pages
Returns a new instance of a BigNumber object with value n , where n is a numeric value in the specified base ,...
Read more >Bignumber.js - JavaScripting
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
Read more >BigInteger Base Conversion - java - Stack Overflow
So in the above code I used String value = bigInteger.toString(finalBase) to return a String representation of the base10 BigInteger in the ...
Read more >server - node_modules - bignumber.js - README.md - GitLab
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic. ... It also does not allow NaN or Infinity , or have the configuration ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m closing it since there was no time to dig deeper. I’ll reopen once I run into this again.
Cool cool. I’ll keep it open.
Keep in mind ethers exposes absolutely zero parts of BN.js. It is not meant to be compatible with BN.js and BigNumber should be thought of as its own implementation of a big number library. There is no way to use any part of BN.js from any export in ethers. 😃