1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* bignum.c (rb_big_rshift): num should be initialized by carry

bits if x is negative.

* bignum.c (bigdivmod): len for bignum zero is 1, not 0.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-10-04 17:54:29 +00:00
parent 1e3062ede1
commit a2c9020808
3 changed files with 13 additions and 2 deletions

View file

@ -11,6 +11,13 @@ Fri Oct 4 13:05:58 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/extmk.rb (create_makefile): add -Wl,-no-undefined to $DLDFLAGS
on Linux if GNU ld is used and --enable-shared is specified.
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.
* bignum.c (bigdivmod): len for bignum zero is 1, not 0.
Thu Oct 3 20:22:11 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* bcc32/mkexports.rb: to work on cygwin via telnet.

View file

@ -1243,7 +1243,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 > 0 && BDIGITS(mod)[0] != 0) {
if (divp) *divp = bigadd(*divp, rb_int2big(1), 0);
if (modp) *modp = bigadd(mod, y, 1);
}
@ -1603,6 +1604,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;

View file

@ -87,7 +87,7 @@ VALUE
rb_obj_type(obj)
VALUE obj;
{
rb_warn("`type' is deprecated; use `class'");
rb_warn("Object#type is deprecated; use Object#class");
return rb_class_real(CLASS_OF(obj));
}