mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge -c 12224
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@12332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
365958f285
commit
cd9df2b896
3 changed files with 39 additions and 21 deletions
|
|
@ -1,3 +1,7 @@
|
|||
Wed May 23 05:35:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* bignum.c (rb_big_pow): truncate all zero BDIGITs. [ruby-dev:30733]
|
||||
|
||||
Wed May 23 05:17:33 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* ext/iconv/iconv.c (iconv_s_conv): rdoc fix.
|
||||
|
|
|
|||
54
bignum.c
54
bignum.c
|
|
@ -96,35 +96,49 @@ rb_big_2comp(x) /* get 2's complement */
|
|||
}
|
||||
|
||||
static VALUE
|
||||
bignorm(x)
|
||||
bigtrunc(x)
|
||||
VALUE x;
|
||||
{
|
||||
if (FIXNUM_P(x)) {
|
||||
return x;
|
||||
}
|
||||
else if (TYPE(x) == T_BIGNUM) {
|
||||
long len = RBIGNUM(x)->len;
|
||||
BDIGIT *ds = BDIGITS(x);
|
||||
long len = RBIGNUM(x)->len;
|
||||
BDIGIT *ds = BDIGITS(x);
|
||||
|
||||
while (len-- && !ds[len]) ;
|
||||
RBIGNUM(x)->len = ++len;
|
||||
while (len-- && !ds[len]);
|
||||
RBIGNUM(x)->len = ++len;
|
||||
return x;
|
||||
}
|
||||
|
||||
if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
|
||||
long num = 0;
|
||||
while (len--) {
|
||||
num = BIGUP(num) + ds[len];
|
||||
static VALUE
|
||||
bigfixize(VALUE x)
|
||||
{
|
||||
long len = RBIGNUM(x)->len;
|
||||
BDIGIT *ds = BDIGITS(x);
|
||||
|
||||
if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
|
||||
long num = 0;
|
||||
while (len--) {
|
||||
num = BIGUP(num) + ds[len];
|
||||
}
|
||||
if (num >= 0) {
|
||||
if (RBIGNUM(x)->sign) {
|
||||
if (POSFIXABLE(num)) return LONG2FIX(num);
|
||||
}
|
||||
if (num >= 0) {
|
||||
if (RBIGNUM(x)->sign) {
|
||||
if (POSFIXABLE(num)) return LONG2FIX(num);
|
||||
}
|
||||
else if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
|
||||
else {
|
||||
if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
|
||||
}
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
bignorm(VALUE x)
|
||||
{
|
||||
if (!FIXNUM_P(x) && TYPE(x) == T_BIGNUM) {
|
||||
x = bigfixize(bigtrunc(x));
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_big_norm(x)
|
||||
VALUE x;
|
||||
|
|
@ -1641,10 +1655,10 @@ rb_big_pow(x, y)
|
|||
while (yy % 2 == 0) {
|
||||
yy /= 2;
|
||||
x = rb_big_mul0(x, x);
|
||||
if (!BDIGITS(x)[RBIGNUM(x)->len-1]) RBIGNUM(x)->len--;
|
||||
bigtrunc(x);
|
||||
}
|
||||
z = rb_big_mul0(z, x);
|
||||
if (!BDIGITS(z)[RBIGNUM(z)->len-1]) RBIGNUM(z)->len--;
|
||||
bigtrunc(z);
|
||||
}
|
||||
return bignorm(z);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define RUBY_RELEASE_DATE "2007-05-23"
|
||||
#define RUBY_VERSION_CODE 186
|
||||
#define RUBY_RELEASE_CODE 20070523
|
||||
#define RUBY_PATCHLEVEL 21
|
||||
#define RUBY_PATCHLEVEL 22
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
#define RUBY_VERSION_MINOR 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue