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

Bigint support #181

Open
protango opened this issue Jul 10, 2021 · 5 comments
Open

Bigint support #181

protango opened this issue Jul 10, 2021 · 5 comments

Comments

@protango
Copy link

With bigint now a part of JavaScript, it would be nice for Decimal.JS to support it within its constructor and operations.

As a workaround we can just convert bigint's to strings before using them in Decimal.JS, however this becomes very repetitive with lots of numbers.

@mahnunchik
Copy link

Any news?

@MikeMcl
Copy link
Owner

MikeMcl commented Aug 17, 2022

@mahnunchik

No news. I'll try and have a look at this soon.

@sterlu
Copy link

sterlu commented Jul 5, 2023

Would you accept a PR which treats BigInt as a string in the constructor? Should be pretty simple to do around here:

if (t === 'bigint') {
  v = v.toString();
  t = 'string';
}

@MikeMcl
Copy link
Owner

MikeMcl commented Jul 5, 2023

@sterlu

Yes, but if the argument is a BigInt then there would be no need for the minus and plus sign checks, or for the isDecimal.test(v), so it would just be a matter of setting x.s to 1 or -1 depending on whether the argument is positive or negative, and then returning parseDecimal(x, v.toString()). Ça va?

@SynthLuvr
Copy link

This would be good to add to make our codebase a little bit more concise. I think @sterlu is on the right track, there wouldn't be too much effort required to add bigint support.

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

No branches or pull requests

5 participants