From 7da40cbcb8861029d2bd5e5b3454b29a86631a01 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 7 Oct 2002 07:16:12 +0000 Subject: [PATCH] * bignum.c (bigdivmod): wrong condition check for Bignum zero. * bignum.c (Init_Bignum): need to add Bignum#div. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ bignum.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d099b1fa88..cf5a0d5d47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Oct 7 15:36:42 2002 Yukihiro Matsumoto + + * bignum.c (bigdivmod): wrong condition check for Bignum zero. + + * bignum.c (Init_Bignum): need to add Bignum#div. + Sun Oct 6 00:49:15 2002 Minero Aoki * eval.c (rb_load): should not pass blocks to the loaded file. diff --git a/bignum.c b/bignum.c index 4db4bdb6a6..0fa2233ebc 100644 --- a/bignum.c +++ b/bignum.c @@ -1244,7 +1244,7 @@ bigdivmod(x, y, divp, modp) bigdivrem(x, y, divp, &mod); if (RBIGNUM(x)->sign != RBIGNUM(y)->sign && - RBIGNUM(mod)->len > 0 && BDIGITS(mod)[0] != 0) { + !(RBIGNUM(mod)->len == 1 && BDIGITS(mod)[0] == 0)) { if (divp) *divp = bigadd(*divp, rb_int2big(1), 0); if (modp) *modp = bigadd(mod, y, 1); } @@ -1730,6 +1730,7 @@ Init_Bignum() rb_define_method(rb_cBignum, "*", rb_big_mul, 1); rb_define_method(rb_cBignum, "/", rb_big_div, 1); rb_define_method(rb_cBignum, "%", rb_big_modulo, 1); + rb_define_method(rb_cBignum, "div", rb_big_div, 1); rb_define_method(rb_cBignum, "divmod", rb_big_divmod, 1); rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1); rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);