diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-10 16:54:43 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-10 16:54:43 +0000 |
commit | 82c719c3376a868834d45c4c995a4a2832616aed (patch) | |
tree | 9dee1ffbae246aee355a5ab85214ed15523bab60 /ext/bigdecimal/bigdecimal.c | |
parent | bd4d9e9a356def5be49b28be86240f5efd04489b (diff) | |
download | ruby-82c719c3376a868834d45c4c995a4a2832616aed.tar.gz |
* 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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 7 |
1 files changed, 5 insertions, 2 deletions
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); |