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

Does it has BigDecimal in mruby? #3646

Open
torsakch opened this issue Apr 30, 2017 · 5 comments
Open

Does it has BigDecimal in mruby? #3646

torsakch opened this issue Apr 30, 2017 · 5 comments

Comments

@torsakch
Copy link

torsakch commented Apr 30, 2017

I found that in some circumstances I need highly precise decimal type for calculation. So does Mruby support BigDecimal or does it has Mruby gems to support that? thanks!! If not, what should I do the achieve that?

@Asmod4n
Copy link
Contributor

Asmod4n commented Apr 30, 2017

There is a gem to add bignum support.
https://github.com/chasonr/mruby-gmp-bignum/ or https://github.com/chasonr/mruby-bignum/
Read the readme on how to use it, because it either needs a forked mruby version or you have to use special functions to do math on them.

@torsakch
Copy link
Author

torsakch commented May 1, 2017

@Asmod4n Thank you very much. However, as my understandings, the gem does not support the BigDecimal. For example, if I want "123456789.123456789 + 123456789.123456789", it should be "246913578.246913578". But for now I got "246913578.246913". Am I correct?

@Asmod4n
Copy link
Contributor

Asmod4n commented May 1, 2017

if you want to use + - * / you have to read the readme of the gem.
It should work with 123456789.123456789.to_bn + 123456789.123456789 but i haven't use those gems yet.

@beoran
Copy link

beoran commented Jul 27, 2017

Since there are external mrbgems to implement bignum, and the ISO standard does not require bignum, I suggest we close this issue as wontfix.

@chasonr
Copy link
Contributor

chasonr commented Sep 16, 2017

Just to clarify: the Bignum gems implement integer arithmetic, not decimal floating point as torsakch seems to want. They could be used as a basis for a BigDecimal class, but they do not provide BigDecimal themselves.

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

4 participants