summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-26 16:20:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-26 16:20:58 +0000
commit5f64ea6c6011ef3c37cb9d36e1958d0008969c30 (patch)
tree851d070ee43222d2fd810026bcebaebc05032cc2 /bignum.c
parent598684944857eac0113fb2ae8e33d3be66931b65 (diff)
downloadruby-5f64ea6c6011ef3c37cb9d36e1958d0008969c30.tar.gz
* bignum.c (rb_cmpint): FIX2INT may fail on LP64 platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 3a317d0065..28b64d9f20 100644
--- a/bignum.c
+++ b/bignum.c
@@ -57,7 +57,12 @@ rb_cmpint(VALUE val, VALUE a, VALUE b)
if (NIL_P(val)) {
rb_cmperr(a, b);
}
- if (FIXNUM_P(val)) return FIX2INT(val);
+ if (FIXNUM_P(val)) {
+ long l = FIX2LONG(val);
+ if (l > 0) return 1;
+ if (l < 0) return -1;
+ return 0;
+ }
if (TYPE(val) == T_BIGNUM) {
if (BIGZEROP(val)) return 0;
if (RBIGNUM_SIGN(val)) return 1;