question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a .toBigInt() method to BigNumber type

See original GitHub issue

Ethers accepts BigInt’s as inputs for BigNumberish types, but getting a BigInt from a returned BigNumber is a bit clunky with BigInt(myBigNumber.toString())

I saw in https://github.com/ethers-io/ethers.js/issues/594#issuecomment-526807810 you mentioned that “There will likely be an instance method that will return a BigInt (similar to the instance.toNumber())”, though that method still doesn’t exist.

I’m happy to submit a PR for it, as long as you still support adding an instance.toBigInt() method, and my only question would be whether to throw or return null on platforms that don’t support BigInt

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Mar 30, 2021

This should now be available in 5.1.0.

Try it out and let me know if there are any issues. 😃

1reaction
ricmoocommented, Mar 30, 2021

I have a bunch of other changes I’m pushing out today with v5.1, and this is something that makes sense for that minor bump. I’ll add it today. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

BigNumber - ethers
A BigNumber is an object which safely allows mathematical operations on numbers of any magnitude. Most operations which need to return a value...
Read more >
BigInt - JavaScript - MDN Web Docs
The best way to achieve nearly the same effect in JavaScript is through the BigInt() function: BigInt(x) uses the same algorithm to convert ......
Read more >
bignumber.js API
The following is an example of how to add a prototype method that emulates JavaScript's Math.round function. Math.ceil , Math.floor and Math.trunc can...
Read more >
How to convert strings to bigInt in JavaScript - Stack Overflow
You can use a JavaScript lib called BigInteger.js for the purpose.it is an arbitrary-length integer library for Javascript, ...
Read more >
BigDecimal toBigInteger() Method in Java - GeeksforGeeks
math.BigDecimal.toBigInteger() is an inbuilt method in java that converts this BigDecimal to a BigInteger. This conversion is analogous to the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found