summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-04 20:10:45 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-04 20:10:45 +0000
commit5f61a22950233184db0771ef743706f7c3f99371 (patch)
tree28ee455885b04363000385b59d057013ee7e8d76 /numeric.c
parentbedda2d27f84ae4b28eed87671abc000e8a0eaf0 (diff)
* 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/trunk@10862 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 5a08f0637b..d5829d14a3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1908,11 +1908,8 @@ fix_plus(VALUE x, VALUE 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;
}
switch (TYPE(y)) {
@@ -1944,11 +1941,8 @@ fix_minus(VALUE x, VALUE 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;
}
switch (TYPE(y)) {