Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for issue #1695 #1703

Merged
merged 1 commit into from

2 participants

@k77ch7

This commit fixes issue #1695.

The cause of this issue is RubyBigDecimal#getVpRubyObjectWithPrec19Inner rounds the RubyRational number.

@enebo enebo merged commit 059e90f into from
@enebo enebo added this to the JRuby 1.7.13 milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 16, 2014
  1. @k77ch7

    fixed issue 1695

    k77ch7 authored
This page is out of date. Refresh to see the latest.
View
2  core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
@@ -462,7 +462,7 @@ private static IRubyObject getVpRubyObjectWithPrec19Inner(ThreadContext context,
long denominator = RubyNumeric.num2long(r.denominator(context));
return new RubyBigDecimal(context.runtime,
- BigDecimal.valueOf(numerator).divide(BigDecimal.valueOf(denominator), getRoundingMode(context.runtime)));
+ BigDecimal.valueOf(numerator).divide(BigDecimal.valueOf(denominator), MathContext.UNLIMITED));
}
private static RubyBigDecimal getVpValueWithPrec19(ThreadContext context, IRubyObject value, long precision, boolean must) {
View
11 spec/regression/GH-1695_bigdecimal_and_rational_multiplication_rounds_the_rational_number.rb
@@ -0,0 +1,11 @@
+require 'rational'
+require 'bigdecimal'
+
+# https://github.com/jruby/jruby/issues/1695
+describe 'BigDecimal#*' do
+ it 'returns correct value' do
+ (BigDecimal.new('100') * Rational(1, 100)).to_i.should == 1
+ (BigDecimal.new('100') * Rational(49, 100)).to_i.should == 49
+ (BigDecimal.new('100') * Rational(50, 100)).to_i.should == 50
+ end
+end
Something went wrong with that request. Please try again.