Skip to content

BigDecimal should accept a Float value without a precision #213

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

Open
mrkn opened this issue Dec 3, 2021 · 1 comment · May be fixed by #314
Open

BigDecimal should accept a Float value without a precision #213

mrkn opened this issue Dec 3, 2021 · 1 comment · May be fixed by #314

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.

@vanboom
Copy link

vanboom commented Nov 30, 2024

👍 Why require precision? Can't it just work like it did in previous ruby versions? This issue is 3 years old - please revert the BigDecimal float behavior to how it worked in previous ruby versions.

@mrzasa mrzasa linked a pull request Feb 4, 2025 that will close this issue
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