summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-08 09:38:16 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-08 09:38:16 +0000
commitdde6b7dd06268221b3e6931ca7582b2da7b52403 (patch)
tree0bdfde93b61d81649427e054af09fc3a7660a82d /bignum.c
parent71ad3aa4ffdf0c5e8b387bb9c258ce1b66d6836e (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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/bignum.c b/bignum.c
index ac84ae4..4d70896 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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'");
}