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 /numeric.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 'numeric.c')
-rw-r--r-- | numeric.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -649,6 +649,16 @@ num2int(val) } } +UINT +num2uint(val) + VALUE val; +{ + if (TYPE(val) == T_BIGNUM) { + return big2uint(val); + } + return (UINT)num2int(val); +} + VALUE num2fix(val) VALUE val; @@ -956,7 +966,7 @@ fix_rev(num) unsigned long val = FIX2UINT(num); val = ~val; - return INT2FIX(val); + return int2inum(val); } static VALUE @@ -968,7 +978,7 @@ fix_and(x, y) if (TYPE(y) == T_BIGNUM) { return big_and(y, x); } - val = NUM2INT(x) & NUM2INT(y); + val = FIX2INT(x) & NUM2INT(y); return int2inum(val); } @@ -981,8 +991,8 @@ fix_or(x, y) if (TYPE(y) == T_BIGNUM) { return big_or(y, x); } - val = NUM2INT(x) | NUM2INT(y); - return INT2FIX(val); + val = FIX2INT(x) | NUM2INT(y); + return int2inum(val); } static VALUE @@ -994,8 +1004,8 @@ fix_xor(x, y) if (TYPE(y) == T_BIGNUM) { return big_xor(y, x); } - val = NUM2INT(x) ^ NUM2INT(y); - return INT2FIX(val); + val = FIX2INT(x) ^ NUM2INT(y); + return int2inum(val); } static VALUE |