Open protango opened 3 years ago
Any news?
@mahnunchik
No news. I'll try and have a look at this soon.
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';
}
@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?
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.
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.