* bignum.c (big2ulong): Add a cast.
(big2ull): Add a specialized code for SIZEOF_LONG_LONG <= SIZEOF_BDIGITS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6dede51159
commit
a8c226922d
@ -1,3 +1,9 @@
|
|||||||
|
Tue Jun 25 19:03:00 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (big2ulong): Add a cast.
|
||||||
|
(big2ull): Add a specialized code for SIZEOF_LONG_LONG <=
|
||||||
|
SIZEOF_BDIGITS.
|
||||||
|
|
||||||
Tue Jun 25 12:42:57 2013 Tanaka Akira <akr@fsij.org>
|
Tue Jun 25 12:42:57 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (integer_unpack_single_bdigit): Use "1 + ~u" instead of
|
* bignum.c (integer_unpack_single_bdigit): Use "1 + ~u" instead of
|
||||||
|
13
bignum.c
13
bignum.c
@ -2423,7 +2423,7 @@ big2ulong(VALUE x, const char *type, int check)
|
|||||||
}
|
}
|
||||||
ds = BDIGITS(x);
|
ds = BDIGITS(x);
|
||||||
#if SIZEOF_LONG <= SIZEOF_BDIGITS
|
#if SIZEOF_LONG <= SIZEOF_BDIGITS
|
||||||
num = ds[0];
|
num = (unsigned long)ds[0];
|
||||||
#else
|
#else
|
||||||
num = 0;
|
num = 0;
|
||||||
while (len--) {
|
while (len--) {
|
||||||
@ -2486,16 +2486,21 @@ big2ull(VALUE x, const char *type)
|
|||||||
{
|
{
|
||||||
long len = RBIGNUM_LEN(x);
|
long len = RBIGNUM_LEN(x);
|
||||||
unsigned LONG_LONG num;
|
unsigned LONG_LONG num;
|
||||||
BDIGIT *ds;
|
BDIGIT *ds = BDIGITS(x);
|
||||||
|
|
||||||
if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS)
|
if (len == 0)
|
||||||
|
return 0;
|
||||||
|
if (BIGSIZE(x) > SIZEOF_LONG_LONG)
|
||||||
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
|
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
|
||||||
ds = BDIGITS(x);
|
#if SIZEOF_LONG_LONG <= SIZEOF_BDIGITS
|
||||||
|
num = (unsigned LONG_LONG)ds[0];
|
||||||
|
#else
|
||||||
num = 0;
|
num = 0;
|
||||||
while (len--) {
|
while (len--) {
|
||||||
num = BIGUP(num);
|
num = BIGUP(num);
|
||||||
num += ds[len];
|
num += ds[len];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user