Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for BigInt? #391

Open
shaunhurley opened this issue May 4, 2022 · 2 comments
Open

Support for BigInt? #391

shaunhurley opened this issue May 4, 2022 · 2 comments

Comments

@shaunhurley
Copy link

Hey folks, curious to understand what (if any) plans you have for supporting the bigint type?

I'm migrating some code to use the latest Square SDK and noticed that they are now returning all numbers as bigint, and creating a currency from a bigint results in a $0.00 value.

currency(100).format() --> $1.00
currency(100n).format() --> $0.00

@scurker
Copy link
Owner

scurker commented May 4, 2022

When this library was first created, BigInt wasn't widely supported across all browsers - but that has certainly changed.

There's some considerations to be made because we'd either have to support BigInt internally, or truncate to the max integer, which negates some of the benefits from using BigInt. I would certainly thing supporting this in the future could be a possibility though.

@shaunhurley
Copy link
Author

I figured as much, and it's not even that there is necessarily a need to work with numbers that big, just that it's becoming more common for source data to be returned in that (bigInt) format - Square (my case in question) is very widely used, for example.

In the short term, since bigInt's stringify to a usable integer (within the bounds of discussions), I am able to resolve my issues by making my current calls with a .toString() on the end of the values. That might be sufficient as a short term (non-breaking) fix for the interim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants