diff --git a/ChangeLog b/ChangeLog index 47ed4db6b8..f268ae3177 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 16 13:51:40 2011 NAKAMURA Usaku + + * bignum.c (rb_big2ulong): need to calc in unsigned long, because + the range of VALUE is larger than it on LLP64 platform, such as Win64. + this change fixes the failures of test/-ext-/num2int. + Wed Nov 16 12:02:47 2011 NAKAMURA Usaku * test/webrick/test_cgi.rb (TestWEBrickCGI#start_cgi_server): there are diff --git a/bignum.c b/bignum.c index a1c4ac78a0..2d61bb37c0 100644 --- a/bignum.c +++ b/bignum.c @@ -1210,11 +1210,11 @@ rb_big2ulong(VALUE x) VALUE num = big2ulong(x, "unsigned long", TRUE); if (!RBIGNUM_SIGN(x)) { - VALUE v = (VALUE)(-(SIGNED_VALUE)num); + unsigned long v = (unsigned long)(-(long)num); if (v <= LONG_MAX) rb_raise(rb_eRangeError, "bignum out of range of unsigned long"); - return v; + return (VALUE)v; } return num; }