mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (fix_plus): addition in Fixnum will never overflow
long. a patch from Ondrej Bilka <neleai at seznam.cz>. [ruby-core:08794] * numeric.c (fix_minus): ditto. * bignum.c (rb_big_pow): eagerly truncate resulting bignum. [ruby-core:08794] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a5913ab9ff
commit
b2b33db355
3 changed files with 15 additions and 8 deletions
11
ChangeLog
11
ChangeLog
|
@ -24,6 +24,17 @@ Tue Sep 5 05:49:41 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* file.c (path_check_0): check if sticky bit is set on parent
|
||||
directories for executable path. fixed: [ruby-dev:29415]
|
||||
|
||||
Tue Sep 5 05:03:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* numeric.c (fix_plus): addition in Fixnum will never overflow
|
||||
long. a patch from Ondrej Bilka <neleai at seznam.cz>.
|
||||
[ruby-core:08794]
|
||||
|
||||
* numeric.c (fix_minus): ditto.
|
||||
|
||||
* bignum.c (rb_big_pow): eagerly truncate resulting bignum.
|
||||
[ruby-core:08794]
|
||||
|
||||
Mon Sep 4 23:15:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* time.c (time_to_s): make it conform to RFC2822 date format.
|
||||
|
|
2
bignum.c
2
bignum.c
|
@ -1617,8 +1617,10 @@ rb_big_pow(x, y)
|
|||
while (yy % 2 == 0) {
|
||||
yy /= 2;
|
||||
x = rb_big_mul(x, x);
|
||||
if (!BDIGITS(x)[RBIGNUM(x)->len-1]) RBIGNUM(x)->len--;
|
||||
}
|
||||
z = rb_big_mul(z, x);
|
||||
if (!BDIGITS(z)[RBIGNUM(z)->len-1]) RBIGNUM(z)->len--;
|
||||
}
|
||||
return bignorm(z);
|
||||
}
|
||||
|
|
10
numeric.c
10
numeric.c
|
@ -1982,11 +1982,8 @@ fix_plus(x, y)
|
|||
a = FIX2LONG(x);
|
||||
b = FIX2LONG(y);
|
||||
c = a + b;
|
||||
r = LONG2FIX(c);
|
||||
r = LONG2NUM(c);
|
||||
|
||||
if (FIX2LONG(r) != c) {
|
||||
r = rb_big_plus(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
if (TYPE(y) == T_FLOAT) {
|
||||
|
@ -2015,11 +2012,8 @@ fix_minus(x, y)
|
|||
a = FIX2LONG(x);
|
||||
b = FIX2LONG(y);
|
||||
c = a - b;
|
||||
r = LONG2FIX(c);
|
||||
r = LONG2NUM(c);
|
||||
|
||||
if (FIX2LONG(r) != c) {
|
||||
r = rb_big_minus(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
if (TYPE(y) == T_FLOAT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue