summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-11 06:47:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-11 06:47:09 +0000
commit1db0db3ba0b90787e9db8c2dc72bfed879d5ee20 (patch)
treea0b9f5b623b16f9436f0a687782c2480b32e93ce /bignum.c
parent4bacdc1e46ab788f9285ccd8eccd2776260f9528 (diff)
* bignum.c (rb_int2big): use SIGNED_VALUE. [ruby-dev:29019]
* bignum.c (rb_int2inum, rb_uint2inum): use VALUE sized integer. * bignum.c (rb_big2long, rb_big2ulong): ditto. * numeric.c (rb_num2long, rb_num2ulong): ditto. * numeric.c (check_int, check_uint): ditto. * bignum.c (rb_quad_pack): typo fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/bignum.c b/bignum.c
index c51f1613b5..8a5dd41782 100644
--- a/bignum.c
+++ b/bignum.c
@@ -192,7 +192,7 @@ rb_quad_pack(char *buf, VALUE val)
BDIGIT *ds;
if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS) {
- len = SIZEOF_LONG/SIZEOF_BDIGITS;
+ len = SIZEOF_LONG_LONG/SIZEOF_BDIGITS;
}
ds = BDIGITS(val);
q = 0;
@@ -686,17 +686,17 @@ rb_big_to_s(int argc, VALUE *argv, VALUE x)
return rb_big2str(x, base);
}
-static unsigned long
+static VALUE
big2ulong(VALUE x, const char *type, int check)
{
long len = RBIGNUM(x)->len;
BDIGIT_DBL num;
BDIGIT *ds;
- if (len > SIZEOF_LONG/SIZEOF_BDIGITS) {
+ if (len > SIZEOF_VALUE/SIZEOF_BDIGITS) {
if (check)
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
- len = SIZEOF_LONG/SIZEOF_BDIGITS;
+ len = SIZEOF_VALUE/SIZEOF_BDIGITS;
}
ds = BDIGITS(x);
num = 0;
@@ -707,23 +707,23 @@ big2ulong(VALUE x, const char *type, int check)
return num;
}
-unsigned long
+VALUE
rb_big2ulong_pack(VALUE x)
{
- unsigned long num = big2ulong(x, "unsigned long", Qfalse);
+ VALUE num = big2ulong(x, "unsigned long", Qfalse);
if (!RBIGNUM(x)->sign) {
return -num;
}
return num;
}
-unsigned long
+VALUE
rb_big2ulong(VALUE x)
{
- unsigned long num = big2ulong(x, "unsigned long", Qtrue);
+ VALUE num = big2ulong(x, "unsigned long", Qtrue);
if (!RBIGNUM(x)->sign) {
- if ((long)num < 0) {
+ if ((SIGNED_VALUE)num < 0) {
rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
}
return -num;
@@ -731,15 +731,16 @@ rb_big2ulong(VALUE x)
return num;
}
-long
+SIGNED_VALUE
rb_big2long(VALUE x)
{
- unsigned long num = big2ulong(x, "long", Qtrue);
+ VALUE num = big2ulong(x, "long", Qtrue);
- if ((long)num < 0 && (RBIGNUM(x)->sign || (long)num != LONG_MIN)) {
+ if ((SIGNED_VALUE)num < 0 &&
+ (RBIGNUM(x)->sign || (SIGNED_VALUE)num != LONG_MIN)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
}
- if (!RBIGNUM(x)->sign) return -(long)num;
+ if (!RBIGNUM(x)->sign) return -(SIGNED_VALUE)num;
return num;
}