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

BigDecimal should accept a Float value without a precision #213

Open
mrkn opened this issue Dec 3, 2021 · 0 comments
Open

BigDecimal should accept a Float value without a precision #213

mrkn opened this issue Dec 3, 2021 · 0 comments

Comments

@mrkn
Copy link
Member

mrkn commented Dec 3, 2021

irb(main):002:0> BigDecimal(5.1)
(irb):2:in `BigDecimal': can't omit precision for a Float. (ArgumentError)
        from (irb):2:in `<main>'
        from /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.8.pre.9/exe/irb:11:in `<top (required)>'
        from /home/mrkn/.rbenv/versions/3.0/bin/irb:23:in `load'
        from /home/mrkn/.rbenv/versions/3.0/bin/irb:23:in `<main>'

This should works like below.

irb(main):003:0> BigDecimal(5.1, Float::DIG+1)
=> 0.51e1

This is necessary to resolve #212.

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

No branches or pull requests

1 participant