Skip to content

BigDecimal arithmetic regression [jruby-9.4] #7650

@klobuczek

Description

@klobuczek

Expected Behavior

2.6.4 :001 > require 'bigdecimal/util'
 => true
2.6.4 :002 > 0.1.to_d
 => 0.1e0
3.1.3 :001 > require 'bigdecimal/util'
 => true
3.1.3 :002 > 0.1.to_d
 => 0.1e0
jruby-9.3.10.0 :001 > require 'bigdecimal/util'
=> true
jruby-9.3.10.0 :002 > 0.1.to_d
=> 0.1e0

Actual Behavior

jruby-9.4.1.0 :002 > require 'bigdecimal/util'
 => true
jruby-9.4.1.0 :003 > 0.1.to_d
 => 0.1000000000000000055511151231257827021181583404541015625e0

I understand that this is what you get with floating point arithmetic and that jruby-9.4 might be even more precise. But did this have to change in jruby-9.4? It leads to lower precision with basic calculations like 0.1.to_d - 0.1 which is not easy to understand for many users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions