diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | bignum.c | 7 |
2 files changed, 10 insertions, 1 deletions
@@ -1,3 +1,7 @@ +Fri Mar 27 01:19:50 2009 Tanaka Akira <akr@fsij.org> + + * bignum.c (rb_cmpint): FIX2INT may fail on LP64 platforms. + Fri Mar 13 21:11:51 2009 Yukihiro Matsumoto <matz@ruby-lang.org> * ext/sdbm/_sdbm.c: should include "ruby/defines.h" as well for @@ -56,7 +56,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; |