Other places you can find me:
srknzl / bigdecimal.js Goto Github PK
View Code? Open in Web Editor NEWBigInt based BigDecimal implementation
Home Page: https://srknzl.github.io/bigdecimal.js
License: Apache License 2.0
BigInt based BigDecimal implementation
Home Page: https://srknzl.github.io/bigdecimal.js
License: Apache License 2.0
Other places you can find me:
Describe the bug
I'm using your library to handle big numbers in my library: https://github.com/macdonaldr93/bloombug-money.
I'm building a React Native app with it and when I run the app I get no identifiers allowed directly after numeric literal
with no stacktrace. I've debugged the issue to this library. I'm able to start a new project in expo, include this library, create a BigDecimal and it breaks.
Expected behavior
Work on Android.
Screenshots
Environment (please complete the following information):
To Reproduce
Additional context
For some reason, big.js
doesn't have this issue.
Hi,
Thank you so much for this package. Its the one and permanent solution for the math blunder in JS. I was wondering if we could create ES Modules of the bigdecimal.js?
I tried creating wrapper around your files which would be a .mjs file. I could not make them work. Let me know if you would be interested in making ES module compatible files.
Regards
Kavya
Example workflow from hazelcast-nodejs-client: https://github.com/hazelcast/hazelcast-nodejs-client/blob/master/.github/workflows/markdown_link_checker.yml
The documentation about MathContext and Mc constructor looks wrong, fix it
https://github.com/srknzl/bigdecimal.js/blob/main/src/bigdecimal.ts#L143
https://github.com/srknzl/bigdecimal.js/blob/main/src/bigdecimal.ts#L4298
Describe the bug
Big(1).divideWithMathContext(Big(3), new MC(0, RoundingMode.CEILING)).numberValue()
throw new RangeError('Non-terminating decimal expansion; no exact representable decimal result.');
1/3 ceiling
i want the result is 1. What should I do?
Is your feature request related to a problem? Please describe.
This package looks great. Thanks for creating it. I wish the bundle size was quite a bit smaller though. Something on the order of big.js
Describe the solution you'd like
One idea would be to create a new package, maybe named bigdecimal-light.js
, that has a comparable set of methods to big.js
.
Describe alternatives you've considered
I don't think forking and removing the methods on my end would be a great solution but I guess it is possible.
Any interest in this idea?
Issue:
"Can't find variable: BigInt" error is thrown on Safari 13 while app load
Can we polyfill BigInt for browsers that do not support BigInt? Can JSBI be used for this case?
Is your feature request related to a problem? Please describe.
Relying on compareTo
is quite verbose and not very comfortable to read or use in my humble opinion.
I think this library will greatly benefit by adding aliases for each comparaison operators.
Describe the solution you'd like
Ideally, I would like to extends the API to support gt
, gte
, lt
, lte
as aliases of compareTo
(for reference: bignumber, big)
I would also like to make equals
less strict by making it an alias for === 0
and rename the current method to strictEquals
when scale matter
if (x.equals(y)) // ===
if (!x.equals(y)) // !==
if (x.strictEquals(y)) // equals in value & scale
if(x.gt(y)) // >
if(x.gte(y)) // >=
if(x.lt(y)) // <
if(x.lte(y)) // <=
If the intention is to keep the API closely related to the JAVA implementation, it is also perfectly fine to find a different alternative for the ===
alias. (ex: sameAs
, similar
, equivalent
, eq
, etc...)
I'm also considering adding notEquals
to the list
Describe alternatives you've considered
Create a new Compare
utils
class Comparator {
constructor(private value: BigDecimal) {}
equals(value: BigDecimal) {
return this.value.compareTo(value) === 0;
}
notEquals(value: BigDecimal) {
return this.value.compareTo(value) !== 0;
}
gt(value: BigDecimal) {
return this.value.compareTo(value) > 0;
}
gte(value: BigDecimal) {
return this.value.compareTo(value) >= 0;
}
lt(value: BigDecimal) {
return this.value.compareTo(value) < 0;
}
lte(value: BigDecimal) {
return this.value.compareTo(value) <= 0;
}
}
function Compare(value: BigDecimal): Comparator {
return new Comparator(value);
}
// if(Compare(x).gte(y))
I'm currently using this util in my own projects to avoid extending the bigdecimal.js
class
Hello!
I just noticed that the following functions add, subtract, multiply, divideWithMathContext , divideToIntegralValue, divideAndRemainder & compareTo use convertToBigDecimal to convert the incoming value as a safety measure.
This code doesn't seem to be present in the Java source code though.
I guess it was done to prevent errors when developers aren't using typescript or to mitigate mistakes if they use it due to the nature of JS ?
In order to match the (un)expected type, I guess it would make more sense to be more flexible and allow any
or BigDecimal | string | number
directly in those methods too ? this would also allow the following notation which happen to be less convoluted:
- bigValue.add(Big(1)).compareTo(Big(0))
+ bigValue.add(1).compareTo(0)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.