diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-05-08 09:38:16 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-05-08 09:38:16 +0000 |
commit | dde6b7dd06268221b3e6931ca7582b2da7b52403 (patch) | |
tree | 0bdfde93b61d81649427e054af09fc3a7660a82d /bignum.c | |
parent | 71ad3aa4ffdf0c5e8b387bb9c258ce1b66d6836e (diff) |
pack/unpack unsigned
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -342,8 +342,8 @@ big_to_s(x) return big2str(x, 10); } -INT -big2int(x) +UINT +big2uint(x) VALUE x; { UINT num; @@ -351,13 +351,22 @@ big2int(x) USHORT *ds; if (len > sizeof(INT)/sizeof(USHORT)) - ArgError("bignum too big to convert into `int'"); + ArgError("bignum too big to convert into `uint'"); ds = BDIGITS(x); num = 0; while (len--) { num = BIGUP(num); num += ds[len]; } + return num; +} + +INT +big2int(x) + VALUE x; +{ + UINT num = big2uint(x); + if ((INT)num < 0) { ArgError("bignum too big to convert into `int'"); } |