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

Is there any reason why this library build on top of BigInt? #2

Closed
roy2100 opened this issue Dec 16, 2020 · 7 comments
Closed

Is there any reason why this library build on top of BigInt? #2

roy2100 opened this issue Dec 16, 2020 · 7 comments

Comments

@roy2100
Copy link

roy2100 commented Dec 16, 2020

I saw that you implement two version of the decimal proposal , one is on top of BIgInt, and another use the decimal.js,
what is the advantage and disadvantage between this two way?

@Yaffle
Copy link
Owner

Yaffle commented Dec 16, 2020

The second is a ready to use decimal library, i am using it to test against my implementation, test.js has some random tests.
While this library is a my try to implement floating point arithmetic on top of bigint.
Would be nice to know why decimal.js is not using bigint...

@roy2100
Copy link
Author

roy2100 commented Dec 16, 2020

I don't konw how the decimal.js being implemented, i think the way that build on top of BigInt will benifit the
native performance, am i correct?

@roy2100
Copy link
Author

roy2100 commented Dec 16, 2020

And i found there is no way transform this library to jsbi, cause that babel plugin can only transform jsbi to native BigInt(not reverse).

@Yaffle
Copy link
Owner

Yaffle commented Dec 16, 2020

I don't konw how the decimal.js being implemented, i think the way that build on top of BigInt will benifit the
native performance, am i correct?

Yes, perhaps, and this is also some separation of code...

@Yaffle
Copy link
Owner

Yaffle commented Dec 16, 2020

And i found there is no way transform this library to jsbi, cause that babel plugin can only transform jsbi to native BigInt(not reverse).

The plugin in readme transforms code to use JSBI

@roy2100
Copy link
Author

roy2100 commented Dec 16, 2020

In fact, i want to implement a

And i found there is no way transform this library to jsbi, cause that babel plugin can only transform jsbi to native BigInt(not reverse).

The plugin in readme transforms code to use JSBI

Sorry, i am wrong, you made a reverse transformer, that's awesome! In fact, i want made a similar library too, to deal with both decimal and bigint, is anything i can help with the code?

@Yaffle
Copy link
Owner

Yaffle commented Dec 16, 2020

The babel plugin is a little buggy right now and needs to be fixed (see Yaffle/babel-plugin-transform-bigint#5 ).
You could try to implement some fast decimal library or update the code of this library :-)
Some benchmark is needed to compare libs.
In this library many things are not perfect like binary to decimal conversion or math functions, not sure as well how to efficiently implement rounding.
Someone also mentions another library - tc39/proposal-decimal#27 (comment) - with a benchmark results...
Btw, I prefer to use BigFloat, as in this case it is possible to use bitwise shifts, which are faster.

@munrocket munrocket mentioned this issue Oct 27, 2022
@Yaffle Yaffle closed this as completed Aug 18, 2023
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

Successfully merging a pull request may close this issue.

2 participants