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

Make BigDecimal::limit work for subtraction and division. Fix issue #1615 #4830

Merged
merged 2 commits into from
Oct 30, 2017

Conversation

MrBerg
Copy link
Contributor

@MrBerg MrBerg commented Oct 27, 2017

No description provided.

Copy link
Member

@kares kares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -1040,7 +1035,9 @@ public IRubyObject op_quo(ThreadContext context, IRubyObject other) {
int pow = len / 4;
int precision = (pow + 1) * 4 * 2;

return divWithScale(context, val, precision);
IRubyObject result = divWithScale(context, val, precision);
if (result.getClass() == RubyBigDecimal.class) return ((RubyBigDecimal) result).setResult();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not an instanceof check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paranoia that there might be some hidden RubyBigDecimal subclass with strange behaviour.

Nah, it can totally be changed to instanceof.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, if you get a chance please adjust - JRuby is quite in control of its sub-classes.
no need for paranoia 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I pushed a fix.

@headius headius added this to the JRuby 9.1.14.0 milestone Oct 30, 2017
@headius
Copy link
Member

headius commented Oct 30, 2017

👍 from me too. I'll merge to master and 9.1.

@headius headius merged commit 850a14b into jruby:master Oct 30, 2017
@MrBerg MrBerg deleted the enforce-bigdecimal-limit branch October 30, 2017 19:08
@headius
Copy link
Member

headius commented Oct 30, 2017

Actually looks like there are other changes to BigDecimal on master that would need to be merged to jruby-9.1 first, like the divWithScale method. I'll try to sort it out.

@headius
Copy link
Member

headius commented Oct 30, 2017

Merged into 9.1 as dc7b498 and 28eb942. The missing commit from master to make it merge nicely was f386054.

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 this pull request may close these issues.

None yet

3 participants