Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Crashing on attempt to convert Rational into BigDecimal #4324
The reproduce script:
require 'bigdecimal' expected = BigDecimal("0.333333333333333333E0") actual = BigDecimal(Rational(1, 3), 0) puts (expected == actual).inspect
CRuby successfully converts
JRuby crashes with
I discovered this bug when trying to fix failings JRuby tests on Rails master.
Here is the problematic line:
Regarding the precision (second argument) from the MRI doc:
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.
I tried to look into how MRI does that, but it's crazy: https://github.com/ruby/ruby/blob/ruby_2_3/ext/bigdecimal/bigdecimal.c#L4688-L4807