Fix bigdecimal spec#1290
Merged
Merged
Conversation
80050d8 to
0833f22
Compare
eregon
reviewed
Oct 10, 2025
| it "raises ArgumentError when Float is used without precision" do | ||
| -> { BigDecimal(1.0) }.should raise_error(ArgumentError) | ||
| it "allows Float without precision" do | ||
| skip if BigDecimal::VERSION < "3.3.0" |
Member
There was a problem hiding this comment.
Could you use a version_is guard instead? (see usages of that for examples)
skip should only be used as last resort if there is no other way, i.e. skip should be avoided as much as possible.
Maybe we should doc that better for skip, how did you find skip BTW?
eregon
reviewed
Oct 10, 2025
eregon
approved these changes
Oct 10, 2025
Member
eregon
left a comment
There was a problem hiding this comment.
Thank you for the PR, it looks good in general.
| @mixed.remainder(@zero).should.nan? | ||
| @zero.remainder(@zero).should.nan? | ||
| it "raises ZeroDivisionError used with zero" do | ||
| skip if BigDecimal::VERSION < "3.3.0" |
Member
There was a problem hiding this comment.
Use version_is instead, and same for other usages of skip
Fix for new feature BigDecimal(float). Fix assertion of BigMath.log not to expect incorrect random digits to be appended. Fix assertion of too-strict precision and assertion that expecting precision to be too loose. Fix divmod, modulo and remainder assertion which was expecting a bug inconsistent with Float as a specification. Remove coerce expectation to add/sub/mult which was dropped because of a bug, and never implemented correctly in BigDecmal.
0833f22 to
4ba0080
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BigDecimal v3.3.1
Fix for new feature
BigDecimal(float)Fix assertion of BigMath.log not to expect incorrect random digits to be appended.
Fix assertion of too-strict precision and assertion that expecting precision to be too loose.
Fix divmod, modulo and remainder assertion which was expecting a bug inconsistent with Float as a specification.
Remove coerce expectation to add/sub/mult which was dropped because of a bug, and never implemented correctly in BigDecimal.
Unlike
+ - *,add sub multis required to calculate within BigDecimal and to return BigDecimal.a.coerce(b) #=> [b2, a2]only guarantees thata2.class == b2.class. Numeric's default behavior is to return[Float, Float]. It's not suitable to convert something to BigDecimal.