diff options
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1210,10 +1210,11 @@ rb_big2ulong(VALUE x) VALUE num = big2ulong(x, "unsigned long", TRUE); if (!RBIGNUM_SIGN(x)) { - if ((long)num < 0) { + VALUE v = (VALUE)(-(SIGNED_VALUE)num); + + if (v <= LONG_MAX) rb_raise(rb_eRangeError, "bignum out of range of unsigned long"); - } - return (VALUE)(-(SIGNED_VALUE)num); + return v; } return num; } |