diff --git a/ChangeLog b/ChangeLog index 9ea0061680..403f28791b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Dec 11 01:48:00 2008 Yukihiro Matsumoto + + * ext/bigdecimal/bigdecimal.c (BigDecimal_round): should be round + to integer. [ruby-dev:37355] + + * ext/bigdecimal/bigdecimal.c (BigDecimal_divmod): division should + be integer. [incompatible] [ruby-dev:37355] + Thu Dec 11 01:21:58 2008 Yukihiro Matsumoto * thread.c (rb_mutex_unlock): shut up warning. a patch from diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index db2debabef..b875f36efa 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1155,7 +1155,7 @@ BigDecimal_divmod(VALUE self, VALUE r) obj = BigDecimal_DoDivmod(self,r,&div,&mod); if(obj!=(VALUE)0) return obj; SAVE(div);SAVE(mod); - obj = rb_assoc_new(ToValue(div), ToValue(mod)); + obj = rb_assoc_new(BigDecimal_to_i(ToValue(div)), ToValue(mod)); return obj; } @@ -1369,6 +1369,9 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self) GUARD_OBJ(c,VpCreateRbObject(mx, "0")); VpSetPrecLimit(pl); VpActiveRound(c,a,sw,iLoc); + if (argc == 0) { + return BigDecimal_to_i(ToValue(c)); + } return ToValue(c); } @@ -1983,7 +1986,7 @@ Init_bigdecimal(void) rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2); rb_define_method(rb_cBigDecimal, "sub", BigDecimal_sub2, 2); rb_define_method(rb_cBigDecimal, "mult", BigDecimal_mult2, 2); - rb_define_method(rb_cBigDecimal, "div",BigDecimal_div2, -1); + rb_define_method(rb_cBigDecimal, "div", BigDecimal_div2, -1); rb_define_method(rb_cBigDecimal, "hash", BigDecimal_hash, 0); rb_define_method(rb_cBigDecimal, "to_s", BigDecimal_to_s, -1); rb_define_method(rb_cBigDecimal, "to_i", BigDecimal_to_i, 0);