summaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-07 16:35:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-07 16:35:59 +0000
commit24e0b176de56f16abc725df85a4a3899ab7aea2b (patch)
tree5b090b0d5730bd14c5b282294b0266756df17aba /numeric.c
parent6ad81effc12f1a29f71141e2eb276614a1a2158d (diff)
downloadruby-24e0b176de56f16abc725df85a4a3899ab7aea2b.tar.gz
ruby-24e0b176de56f16abc725df85a4a3899ab7aea2b.tar.xz
ruby-24e0b176de56f16abc725df85a4a3899ab7aea2b.zip
* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/numeric.c b/numeric.c
index c5e9893c0..3ae1c283d 100644
--- a/numeric.c
+++ b/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) {