mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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/branches/ruby_1_6@2941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dfe4f687e1
commit
753450b7c4
2 changed files with 19 additions and 1 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,9 @@
|
|||
Mon Oct 7 15:36:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* bignum.c (bigdivmod): wrong condition check for Bignum zero.
|
||||
|
||||
* bignum.c (Init_Bignum): need to add Bignum#div.
|
||||
|
||||
Sun Oct 6 06:11:19 2002 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* eval.c (rb_load): should not pass block to the loaded file.
|
||||
|
@ -11,6 +17,13 @@ Fri Oct 4 14:23:08 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
|||
|
||||
* configure.in (RUBY_MINGW32): backport from 1.7.
|
||||
|
||||
Fri Oct 4 02:21:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* bignum.c (rb_big_rshift): num should be initialized by carry
|
||||
bits if x is negative. (ruby-bugs-ja:PR#347)
|
||||
|
||||
* bignum.c (bigdivmod): len for bignum zero is 1, not 0.
|
||||
|
||||
Thu Oct 3 20:09:52 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* ext/tcltklib/tcltklib.c (invoke_queue_handler): make singleton
|
||||
|
|
7
bignum.c
7
bignum.c
|
@ -951,7 +951,8 @@ bigdivmod(x, y, divp, modp)
|
|||
VALUE mod;
|
||||
|
||||
bigdivrem(x, y, divp, &mod);
|
||||
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign && RBIGNUM(mod)->len > 0) {
|
||||
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign &&
|
||||
!(RBIGNUM(mod)->len == 1 && BDIGITS(mod)[0] == 0)) {
|
||||
if (divp) *divp = bigadd(*divp, rb_int2big(1), 0);
|
||||
if (modp) *modp = bigadd(mod, y, 1);
|
||||
}
|
||||
|
@ -1313,6 +1314,9 @@ rb_big_rshift(x, y)
|
|||
xds = BDIGITS(x);
|
||||
i = RBIGNUM(x)->len; j = i - s1;
|
||||
z = bignew(j, RBIGNUM(x)->sign);
|
||||
if (!RBIGNUM(x)->sign) {
|
||||
num = ((BDIGIT_DBL)~0) << BITSPERDIG;
|
||||
}
|
||||
zds = BDIGITS(z);
|
||||
while (i--, j--) {
|
||||
num = (num | xds[i]) >> s2;
|
||||
|
@ -1445,6 +1449,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue