Skip to content

Loss of precision on BigDecimal operations starting from 1.7.20 #3846

@cburgmer

Description

@cburgmer

Two examples:

$ irb
io/console not supported; tty will not be manipulated
irb(main):001:0> RUBY_DESCRIPTION
=> "jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on Java HotSpot(TM) 64-Bit Server VM 1.8.0_51-b16 [Windows 7-amd64]"
irb(main):002:0> require 'bigdecimal'
=> true
irb(main):003:0> BigDecimal.new("1") / BigDecimal.new("3")
=> #<BigDecimal:6e6d5d29,'0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333E0',200(204)>

vs

$ irb
io/console not supported; tty will not be manipulated
irb(main):001:0> RUBY_DESCRIPTION
=> "jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.8.0_51-b16 [Windows 7-amd64]"
irb(main):002:0> require 'bigdecimal'
=> true
irb(main):003:0> BigDecimal.new("1") / BigDecimal.new("3")
=> #<BigDecimal:13d9cbf5,'0.33333333E0',8(12)>

I would expect full precision, as previous versions of JRuby offered. The change in newer versions hasn't been flagged in the changelogs. I am assuming the change was introduced in #2537.

Considering this change is expected - unless the intention of it is made clear and an alternate solution exists, this is a blocker for us upgrading to newer JRuby versions, as it breaks existing behaviour.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions