Project

General

Profile

Bug #12780 ยป bigdecimal_round.diff

Gat (Dawid Janczak), 09/21/2016 10:47 AM

View differences:

ext/bigdecimal/bigdecimal.c
1736 1736
    GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
1737 1737
    VpSetPrecLimit(pl);
1738 1738
    VpActiveRound(c, a, sw, iLoc);
1739
    if (argc == 0) {
1740
	return BigDecimal_to_i(ToValue(c));
1741
    }
1742 1739
    return ToValue(c);
1743 1740
}
1744 1741

  
test/bigdecimal/test_bigdecimal.rb
876 876
    assert_equal(3.142, BigDecimal.new("3.14159").round(3))
877 877
    assert_equal(13300.0, BigDecimal.new("13345.234").round(-2))
878 878

  
879
    assert_equal(BigDecimal, BigDecimal.new("3.28").round.class)
880

  
879 881
    x = BigDecimal.new("111.111")
880 882
    assert_equal(111    , x.round)
881 883
    assert_equal(111.1  , x.round(1))