You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ jruby -v --dev demo.rb
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 [darwin-x86_64]
Unhandled Java exception: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
divide at java/math/BigDecimal.java:1690
divide at java/math/BigDecimal.java:1723
newInstance at org/jruby/ext/bigdecimal/RubyBigDecimal.java:490
newInstance at org/jruby/ext/bigdecimal/RubyBigDecimal.java:626
newBigDecimal at org/jruby/ext/bigdecimal/RubyBigDecimal.java:226
call at org/jruby/ext/bigdecimal/RubyBigDecimal$BigDecimalKernelMethods$INVOKER$s$0$1$newBigDecimal.gen:-1
call at org/jruby/internal/runtime/methods/JavaMethod.java:724
call at org/jruby/internal/runtime/methods/DynamicMethod.java:208
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:358
call at org/jruby/runtime/callsite/CachingCallSite.java:195
processCall at org/jruby/ir/interpreter/InterpreterEngine.java:324
interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:112
execute at org/jruby/ir/interpreter/Interpreter.java:99
execute at org/jruby/ir/interpreter/Interpreter.java:35
execute at org/jruby/ir/IRTranslator.java:42
runInterpreter at org/jruby/Ruby.java:867
runInterpreter at org/jruby/Ruby.java:871
runNormally at org/jruby/Ruby.java:766
runNormally at org/jruby/Ruby.java:779
runFromMain at org/jruby/Ruby.java:592
doRunFromMain at org/jruby/Main.java:425
internalRun at org/jruby/Main.java:313
run at org/jruby/Main.java:242
main at org/jruby/Main.java:204
I discovered this bug when trying to fix failings JRuby tests on Rails master.
Here is the problematic line: BigDecimal(Rational(1, 3), 0).
Regarding the precision (second argument) from the MRI doc:
If omitted or 0, the number of significant digits is determined from the initial value.
It looks like JRuby is missing the "number of significant digits is determined from the initial value" part. Currently it doesn't follow the MRI behaviour.
Environment
jruby 9.1.6.0 (2.3.1) 2016-11-09
macOS 10.12.1
The reproduce script:
Expected Behavior
CRuby successfully converts
Rational
intoBigDecimal
:Actual Behavior
JRuby crashes with
java.lang.ArithmeticException
.I discovered this bug when trying to fix failings JRuby tests on Rails master.
@enebo @headius @guilleiguaran
The text was updated successfully, but these errors were encountered: