Skip to content

BigDecimal::limit has not effect #1615

@nmk

Description

@nmk

Using BigDecimal::limit has not effect on following computations with BigDecimal instances. This works in MRI 1.9.3 and later.

Compare the following two sessions:

MRI (1.9.3-p545):

~ $ irb -r"bigdecimal" -r "bigdecimal/util"
1.9.3-p545 :001 > BigDecimal.limit(3)
 => 0
1.9.3-p545 :002 > 10.to_d / 3.to_d
 => #<BigDecimal:7fd034801d38,'0.333E1',18(36)>
1.9.3-p545 :003 > (10.to_d / 3.to_d).to_f
 => 3.33
1.9.3-p545 :004 > (10.to_d / 3.to_d).to_s("F")
 => "3.33"  

Latest JRuby (1.7.11):

~ $ irb -r"bigdecimal" -r"bigdecimal/util"
jruby-1.7.11 :001 > BigDecimal.limit(3)
 => 0
jruby-1.7.11 :002 > 10.to_d / 3.to_d
 => #<BigDecimal:136c2147,'0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333E1',200(204)>
jruby-1.7.11 :003 > (10.to_d / 3.to_d).to_f
 => 3.3333333333333335
jruby-1.7.11 :004 > (10.to_d / 3.to_d).to_s("F")
 => "3.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions