32 #if defined __MINGW32__ 33 #define USHORT _USHORT 36 #define BDIGITS(x) (RBIGNUM_DIGITS(x)) 37 #define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT) 38 #define BIGRAD ((BDIGIT_DBL)1 << BITSPERDIG) 39 #define BIGRAD_HALF ((BDIGIT)(BIGRAD >> 1)) 40 #define DIGSPERLONG (SIZEOF_LONG/SIZEOF_BDIGITS) 42 # define DIGSPERLL (SIZEOF_LONG_LONG/SIZEOF_BDIGITS) 44 #define BIGUP(x) ((BDIGIT_DBL)(x) << BITSPERDIG) 45 #define BIGDN(x) RSHIFT((x),BITSPERDIG) 46 #define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1))) 47 #define BDIGMAX ((BDIGIT)-1) 49 #define BIGZEROP(x) (RBIGNUM_LEN(x) == 0 || \ 50 (BDIGITS(x)[0] == 0 && \ 51 (RBIGNUM_LEN(x) == 1 || bigzero_p(x)))) 53 #define BIGNUM_DEBUG 0 55 #define ON_DEBUG(x) do { x; } while (0) 105 if (l < 0)
return -1;
118 #define RBIGNUM_SET_LEN(b,l) \ 119 ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \ 120 (void)(RBASIC(b)->flags = \ 121 (RBASIC(b)->flags & ~RBIGNUM_EMBED_LEN_MASK) | \ 122 ((l) << RBIGNUM_EMBED_LEN_SHIFT)) : \ 123 (void)(RBIGNUM(b)->as.heap.len = (l))) 134 RBIGNUM(big)->as.heap.digits = ds;
140 ds =
RBIGNUM(big)->as.heap.digits;
177 RBIGNUM(big)->as.heap.len = len;
183 #define bignew(len,sign) bignew_1(rb_cBignum,(len),(sign)) 188 return bignew(len, sign != 0);
210 while (
i--) ds[
i] = ~ds[
i];
236 if (len == 0)
return x;
237 while (--len && !ds[len]);
250 if (len == 0)
return INT2FIX(0);
253 #if 2*SIZEOF_BDIGITS > SIZEOF_LONG 257 num = (long)(
BIGUP(num) + ds[len]);
303 while (--
i && !digits[
i]) ;
316 u = 1 + (
VALUE)(-(n + 1));
343 #if SIZEOF_LONG % SIZEOF_BDIGITS != 0 344 # error unexpected SIZEOF_LONG : SIZEOF_BDIGITS ratio 377 buf[0] = (
unsigned long)tmp;
378 tmp = tmp < 0 ? ~0L : 0;
379 for (
i = 1;
i < num_longs;
i++)
380 buf[
i] = (
unsigned long)tmp;
387 for (
i = 0;
i < num_longs && ds < dend;
i++) {
389 for (j = 0; j <
DIGSPERLONG && ds < dend; j++, ds++) {
390 l |= ((
unsigned long)*ds << (j *
BITSPERDIG));
394 for (;
i < num_longs;
i++)
397 for (
i = 0;
i < num_longs;
i++) {
400 for (
i = 0;
i < num_longs;
i++) {
413 while (2 <= num_longs) {
414 if (
buf[num_longs-1] == 0 && (
long)
buf[num_longs-2] >= 0)
416 else if (
buf[num_longs-1] == ~0UL && (
long)
buf[num_longs-2] < 0)
423 else if (num_longs == 1)
432 for (
i = 0;
i < num_longs;
i++) {
433 unsigned long d =
buf[
i];
434 #if SIZEOF_LONG == SIZEOF_BDIGITS 444 if ((
long)
buf[num_longs-1] < 0) {
454 #if SIZEOF_LONG_LONG == QUAD_SIZE && SIZEOF_BDIGITS*2 == SIZEOF_LONG_LONG 480 memcpy(
buf, (
char*)&q, SIZEOF_LONG_LONG);
486 unsigned LONG_LONG q;
492 memcpy(&q,
buf, SIZEOF_LONG_LONG);
495 if ((LONG_LONG)q < 0) {
505 big =
bignew(DIGSPERLL, 1);
507 while (
i < DIGSPERLL) {
513 while (
i-- && !digits[
i]) ;
528 for (
i = 0;
i < len;
i++)
530 for (
i = 0;
i < len;
i++) {
558 #define BNEG(b) (RSHIFT(((BDIGIT*)(b))[QUAD_SIZE/SIZEOF_BDIGITS-1],BITSPERDIG-1) != 0) 567 char *tmp = (
char*)
BDIGITS(big);
583 char sign = 1, nondigit = 0;
592 #define ISDIGIT(c) ('0' <= (c) && (c) <= '9') 593 #define conv_digit(c) \ 594 (!ISASCII(c) ? -1 : \ 595 ISDIGIT(c) ? ((c) - '0') : \ 596 ISLOWER(c) ? ((c) - 'a' + 10) : \ 597 ISUPPER(c) ? ((c) - 'A' + 10) : \ 601 if (badcheck)
goto bad;
609 else if (str[0] ==
'-') {
613 if (str[0] ==
'+' || str[0] ==
'-') {
614 if (badcheck)
goto bad;
636 else if (base < -1) {
646 if (str[0] ==
'0' && (str[1] ==
'b'||str[1] ==
'B')) {
654 if (str[0] ==
'0' && (str[1] ==
'o'||str[1] ==
'O')) {
657 case 4:
case 5:
case 6:
case 7:
661 if (str[0] ==
'0' && (str[1] ==
'd'||str[1] ==
'D')) {
664 case 9:
case 11:
case 12:
case 13:
case 14:
case 15:
669 if (str[0] ==
'0' && (str[1] ==
'x'||str[1] ==
'X')) {
674 if (base < 2 || 36 < base) {
687 while ((c = *++str) ==
'0' || c ==
'_') {
694 if (!(c = *str) ||
ISSPACE(c)) --str;
698 if (c < 0 || c >= base) {
699 if (badcheck)
goto bad;
702 len *=
strlen(str)*
sizeof(char);
704 if ((
size_t)len <= (
sizeof(long)*
CHAR_BIT)) {
707 if (str < end && *end ==
'_')
goto bigparse;
709 if (end == str)
goto bad;
710 while (*end &&
ISSPACE(*end)) end++;
729 if (badcheck && *str ==
'_')
goto bad;
733 for (
i=len;
i--;) zds[
i]=0;
734 while ((c = *str++) != 0) {
737 if (badcheck)
goto bad;
746 if (c >= base)
break;
765 if (s+1 < str && str[-1] ==
'_')
goto bad;
766 while (*str &&
ISSPACE(*str)) str++;
811 rb_ull2big(
unsigned LONG_LONG n)
818 big =
bignew(DIGSPERLL, 1);
820 while (
i < DIGSPERLL) {
826 while (
i-- && !digits[
i]) ;
832 rb_ll2big(LONG_LONG n)
849 rb_ull2inum(
unsigned LONG_LONG n)
852 return rb_ull2big(n);
856 rb_ll2inum(LONG_LONG n)
881 #define POW2_P(x) (((x)&((x)-1))==0) 887 # define MASK_55 0x5555555555555555UL 888 # define MASK_33 0x3333333333333333UL 889 # define MASK_0f 0x0f0f0f0f0f0f0f0fUL 891 # define MASK_55 0x55555555UL 892 # define MASK_33 0x33333333UL 893 # define MASK_0f 0x0f0f0f0fUL 903 return (
int)(x & 0x7f);
909 static inline unsigned long 934 return (
int)
ones(x) - 1;
943 #define LOG2_KARATSUBA_DIGITS 7 944 #define KARATSUBA_DIGITS (1L<<LOG2_KARATSUBA_DIGITS) 945 #define MAX_BIG2STR_TABLE_ENTRIES 64 953 for (
i = 0;
i < 35; ++
i) {
980 rb_bug(
"n1 > KARATSUBA_DIGITS");
983 if (m1) *m1 = 1 << m;
1013 static const double log_2[] = {
1014 1.0, 1.58496250072116, 2.0,
1015 2.32192809488736, 2.58496250072116, 2.8073549220576,
1016 3.0, 3.16992500144231, 3.32192809488736,
1017 3.4594316186373, 3.58496250072116, 3.70043971814109,
1018 3.8073549220576, 3.90689059560852, 4.0,
1019 4.08746284125034, 4.16992500144231, 4.24792751344359,
1020 4.32192809488736, 4.39231742277876, 4.4594316186373,
1021 4.52356195605701, 4.58496250072116, 4.64385618977472,
1022 4.70043971814109, 4.75488750216347, 4.8073549220576,
1023 4.85798099512757, 4.90689059560852, 4.95419631038688,
1024 5.0, 5.04439411935845, 5.08746284125034,
1025 5.12928301694497, 5.16992500144231
1029 if (base < 2 || 36 < base)
1030 rb_bug(
"invalid radix %d", base);
1033 bits = (SIZEOF_LONG*
CHAR_BIT - 1)/2 + 1;
1046 return (
long)ceil(((
double)bits)/log_2[base - 2]);
1055 while (
i && j > 0) {
1060 num =
BIGUP(num) + ds[k];
1061 ds[k] = (
BDIGIT)(num / hbase);
1064 if (trim && ds[
i-1] == 0)
i--;
1070 if (trim &&
i == 0 && num == 0)
break;
1074 while (j < len && ptr[j] ==
'0') j++;
1075 MEMMOVE(ptr, ptr + j,
char, len - j);
1083 long n1,
long len,
long hbase,
int trim)
1091 memset(ptr,
'0', len);
1103 len - m1, hbase, trim);
1106 m1, hbase, !lh && trim);
1117 long n1, n2, len, hbase;
1127 if (base < 2 || 36 < base)
1137 #if SIZEOF_BDIGITS > 2 1144 len = off +
big2str_orig(xx, base, ptr + off, n2, hbase, trim);
1183 if (
argc == 0) base = 10;
1235 if (num == 1+(
unsigned long)(-(
LONG_MIN+1)))
1255 if (num == 1+(
unsigned long)(-(
LONG_MIN+1)))
1263 static unsigned LONG_LONG
1284 unsigned LONG_LONG num = big2ull(x,
"unsigned long long");
1290 if (num <= LLONG_MAX)
1291 return -(LONG_LONG)num;
1292 if (num == 1+(
unsigned LONG_LONG)(-(LLONG_MIN+1)))
1302 unsigned LONG_LONG num = big2ull(x,
"long long");
1305 if (LLONG_MAX < num)
1310 if (num <= LLONG_MAX)
1311 return -(LONG_LONG)num;
1312 if (num == 1+(
unsigned LONG_LONG)(-(LLONG_MIN+1)))
1327 double u = (d < 0)?-d:d;
1364 y = x >> 64;
if (y) {n -= 64; x = y;}
1367 y = x >> 32;
if (y) {n -= 32; x = y;}
1370 y = x >> 16;
if (y) {n -= 16; x = y;}
1372 y = x >> 8;
if (y) {n -= 8; x = y;}
1373 y = x >> 4;
if (y) {n -= 4; x = y;}
1374 y = x >> 2;
if (y) {n -= 2; x = y;}
1375 y = x >> 1;
if (y) {
return n - 2;}
1400 if (bits && (dl & (1UL << (bits %=
BITSPERDIG)))) {
1401 int carry = dl & ~(~(
BDIGIT)0 << bits);
1404 if ((carry = ds[
i]) != 0)
break;
1408 dl &= (
BDIGIT)~0 << bits;
1468 if (yd > 0.0)
return INT2FIX(-1);
1473 #if SIZEOF_LONG * CHAR_BIT < DBL_MANT_DIG 1501 if (yf == 0.0 || rel !=
INT2FIX(0))
1520 #if SIZEOF_LONG * CHAR_BIT < DBL_MANT_DIG 1583 while (xlen-- && (xds[xlen]==yds[xlen]));
1584 if (-1 == xlen)
return INT2FIX(0);
1585 return (xds[xlen] > yds[xlen]) ?
1801 for (
i = 0, num = 0;
i < yn;
i++) {
1806 while (num &&
i < xn) {
1830 z = x; x = y; y = z;
1837 if (xds[
i] > yds[
i]) {
1840 if (xds[
i] < yds[
i]) {
1841 z = x; x = y; y = z;
1873 #if SIZEOF_BDIGITS == SIZEOF_LONG 1875 if (xn == 1 && num < 0) {
1881 zds[0] =
BIGLO(num);
1886 for (
i=0;
i<(int)(
sizeof(y)/
sizeof(
BDIGIT));
i++) {
1893 while (num &&
i < xn) {
1930 #if SIZEOF_BDIGITS == SIZEOF_LONG 1932 zds[0] =
BIGLO(num);
1937 for (
i=0;
i<(int)(
sizeof(y)/
sizeof(
BDIGIT));
i++) {
1944 while (num &&
i < xn) {
1949 if (num) zds[
i++] = (
BDIGIT)num;
1950 else while (
i < xn) {
1970 tds = xds; xds = yds; yds = tds;
1971 i = xn; xn = yn; yn =
i;
1980 while (num &&
i < yn) {
1989 if (num) zds[
i++] = (
BDIGIT)num;
2004 if (sign)
return bigsub(y, x);
2102 while (--
i && !xds[
i]);
2135 while (j--) zds[j] = 0;
2136 for (
i = 0;
i < xl;
i++) {
2139 if (dd == 0)
continue;
2141 for (j = 0; j < yl; j++) {
2143 n = zds[
i + j] + ee;
2144 if (ee) zds[
i + j] =
BIGLO(n);
2162 long i, xn, yn, r, n;
2163 BDIGIT *yds, *zds, *t1ds;
2167 assert(2 * xn <= yn || 3 * xn <= 2*(yn+2));
2176 for (
i = 0;
i < xn + yn;
i++) zds[
i] = 0;
2180 r = xn > yn ? yn : xn;
2211 while (--hn && !vds[hn + ln]);
2217 while (--ln && !vds[ln]);
2230 long i, n, xn, yn, t1n, t2n;
2231 VALUE xh, xl, yh, yl, z, t1, t2, t3;
2266 for (
i = 2 * n + t1n;
i < xn + yn;
i++) zds[
i] = 0;
2275 for (
i = t2n;
i < 2 * n;
i++) zds[
i] = 0;
2282 for (
i = 0;
i < 2 * n;
i++) zds[
i] = 0;
2287 t3 = xl; xl = xh; xh = t3;
2297 t3 = yl; yl = yh; yh = t3;
2339 *zds-- = num | xds[--xn]>>s3;
2344 for (
i = s1;
i > 0; --
i)
2365 while (
i < xn - s1 - 1) {
2366 xds[
i++] = (
BDIGIT)(*zds<<s3) | num;
2377 VALUE v0, v12, v1, v2;
2395 VALUE x0, x1, x2, y0, y1, y2;
2396 VALUE u0, u1, u2, u3, u4, v1, v2, v3;
2397 VALUE z0, z1, z2, z3, z4, z, t;
2407 y0 = x0; y1 = x1; y2 = x2;
2464 v1 = u1; v2 = u2; v3 = u3;
2502 v1 = v2 = v3 =
Qnil;
2569 for (
i = 2 * len + 1;
i--; ) zds[
i] = 0;
2570 for (
i = 0;
i < len;
i++) {
2577 for (j =
i + 1; j < len; j++) {
2589 if (c) zds[
i + len + 1] += (
BDIGIT)c;
2594 #define KARATSUBA_MUL_DIGITS 70 2595 #define TOOM3_MUL_DIGITS 150 2623 t = x; x = y; y = t;
2624 tn = xn; xn = yn; yn = tn;
2647 else if (3*xn <= 2*(yn + 2))
2706 i = bds->
nyzero; num = 0; t2 = 0;
2710 ee = num -
BIGLO(t2);
2718 i = 0; num = 0; q--;
2729 }
while (--
j >=
ny);
2756 if (modp) *modp = x;
2774 if (divp) *divp = z;
2813 while (
j--)
zds[
j] = xds[
j];
2823 if (
nx > 10000 ||
ny > 10000) {
2852 t2 = (t2 |
zds[
i]) >> dd;
3035 BDIGIT bits = (~0 << nb);
3067 #define DBL_BIGDIG ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG) 3099 #if SIZEOF_LONG > SIZEOF_INT 3103 if (l < INT_MIN)
return DBL2NUM(0.0);
3189 rb_warn(
"in a**b, b may be too big");
3203 const long BIGLEN_LIMIT =
BITSPERDIG*1024*1024;
3205 if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) {
3206 rb_warn(
"in a**b, b may be too big");
3210 for (mask =
FIXNUM_MAX + 1; mask; mask >>= 1) {
3236 if (y == 0)
return INT2FIX(0);
3240 #if SIZEOF_BDIGITS == SIZEOF_LONG 3250 #if SIZEOF_BDIGITS == SIZEOF_LONG 3252 zds[0] = xds[0] & y;
3257 for (
i=0;
i<(int)(
sizeof(y)/
sizeof(
BDIGIT));
i++) {
3264 zds[
i] = sign?0:xds[
i];
3281 volatile VALUE x, y, z;
3321 for (
i=0;
i<l1;
i++) {
3322 zds[
i] = ds1[
i] & ds2[
i];
3325 zds[
i] = sign?0:ds2[
i];
3346 #if SIZEOF_BDIGITS == SIZEOF_LONG 3348 zds[0] = xds[0] | y;
3353 for (
i=0;
i<(int)(
sizeof(y)/
sizeof(
BDIGIT));
i++) {
3377 volatile VALUE x, y, z;
3417 for (
i=0;
i<l1;
i++) {
3418 zds[
i] = ds1[
i] | ds2[
i];
3436 sign = (y >= 0) ? 1 : 0;
3442 #if SIZEOF_BDIGITS == SIZEOF_LONG 3444 zds[0] = xds[0] ^ y;
3449 for (
i=0;
i<(int)(
sizeof(y)/
sizeof(
BDIGIT));
i++) {
3456 zds[
i] = sign?xds[
i]:~xds[
i];
3472 volatile VALUE x, y;
3515 for (
i=0;
i<l1;
i++) {
3516 zds[
i] = ds1[
i] ^ ds2[
i];
3519 zds[
i] = sign?ds2[
i]:~ds2[
i];
3561 if (!
NIL_P(t))
return t;
3587 for (
i=0;
i<s1;
i++) {
3591 for (
i=0;
i<len;
i++) {
3625 if (!
NIL_P(t))
return t;
3649 volatile VALUE save_x;
3674 num = (num | xds[
i]) >> s2;
3734 while (num += ~xds[
i], ++
i <= s1) {
VALUE rb_big_modulo(VALUE x, VALUE y)
static VALUE bigdivrem(VALUE, VALUE, volatile VALUE *, volatile VALUE *)
int rb_bigzero_p(VALUE x)
static VALUE bignorm(VALUE x)
#define MEMCMP(p1, p2, type, n)
VALUE rb_big_clone(VALUE x)
static VALUE bigtrunc(VALUE x)
void rb_bug(const char *fmt,...)
VALUE rb_num_coerce_bin(VALUE, VALUE, ID)
VALUE rb_uint2big(VALUE n)
static VALUE rb_big_even_p(VALUE num)
static VALUE big_shift(VALUE x, long n)
size_t strlen(const char *)
static void big_split(VALUE v, long n, volatile VALUE *ph, volatile VALUE *pl)
static VALUE big2str_power_cache[35][MAX_BIG2STR_TABLE_ENTRIES]
#define MAX_BIG2STR_TABLE_ENTRIES
static VALUE check_shiftdown(VALUE y, VALUE x)
VALUE rb_big_xor(VALUE xx, VALUE yy)
VALUE rb_big2ulong(VALUE x)
static void rb_big_realloc(VALUE big, long len)
static VALUE rb_big_size(VALUE big)
static void * bigdivrem1(void *ptr)
static VALUE bigmul1_single(VALUE x, VALUE y)
static VALUE bigsqr_fast(VALUE x)
void rb_big_pack(VALUE val, unsigned long *buf, long num_longs)
static void rb_big_stop(void *ptr)
static VALUE dbl2big(double d)
const char ruby_digitmap[]
static VALUE big_lt(VALUE x, VALUE y)
VALUE rb_big_eql(VALUE x, VALUE y)
VALUE rb_big_plus(VALUE x, VALUE y)
#define RBIGNUM_SET_LEN(b, l)
static VALUE rb_big_abs(VALUE x)
void rb_must_asciicompat(VALUE)
static unsigned long next_pow2(register unsigned long x)
#define bignew(len, sign)
st_index_t rb_memhash(const void *ptr, long len)
static int bdigbitsize(BDIGIT x)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_big_and(VALUE xx, VALUE yy)
static long big_real_len(VALUE x)
static VALUE bigfixize(VALUE x)
VALUE rb_big_fdiv(VALUE x, VALUE y)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_quad_unpack(const char *buf, int sign)
static int ceil_log2(register unsigned long x)
VALUE rb_integer_float_cmp(VALUE x, VALUE y)
static VALUE rb_big_neg(VALUE x)
static VALUE bigadd_int(VALUE x, long y)
double rb_big2dbl(VALUE x)
static void power_cache_init(void)
#define rb_complex_raw1(x)
static long big2str_orig(VALUE x, int base, char *ptr, long len, long hbase, int trim)
void rb_big_resize(VALUE big, long len)
static VALUE big_le(VALUE x, VALUE y)
VALUE rb_big_unpack(unsigned long *buf, long num_longs)
VALUE rb_big_new(long len, int sign)
#define LOG2_KARATSUBA_DIGITS
int rb_cmpint(VALUE val, VALUE a, VALUE b)
VALUE rb_fix2str(VALUE, int)
const char * rb_obj_classname(VALUE)
static VALUE bigmul1_toom3(VALUE x, VALUE y)
static VALUE rb_big_aref(VALUE x, VALUE y)
static int floor_log2(register unsigned long x)
#define NEWOBJ_OF(obj, type, klass, flags)
static VALUE rb_big_divide(VALUE x, VALUE y, ID op)
#define RB_TYPE_P(obj, type)
VALUE rb_big2ulong_pack(VALUE x)
VALUE rb_big_divmod(VALUE x, VALUE y)
#define MEMZERO(p, type, n)
#define rb_rational_raw1(x)
VALUE rb_dbl2big(double d)
VALUE rb_big_eq(VALUE x, VALUE y)
static void bigsub_core(BDIGIT *xds, long xn, BDIGIT *yds, long yn, BDIGIT *zds, long zn)
#define RBIGNUM_POSITIVE_P(b)
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
#define BDIGIT_DBL_SIGNED
static void biglsh_bang(BDIGIT *xds, long xn, unsigned long shift)
static VALUE big_op(VALUE x, VALUE y, enum big_op_t op)
static VALUE bigxor_int(VALUE x, long y)
VALUE rb_big_cmp(VALUE x, VALUE y)
#define STRTOUL(str, endptr, base)
static VALUE bigor_int(VALUE x, long y)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static VALUE bigmul0(VALUE x, VALUE y)
void rb_gc_register_mark_object(VALUE obj)
#define MEMCPY(p1, p2, type, n)
RUBY_EXTERN int isinf(double)
SIGNED_VALUE rb_big2long(VALUE x)
static VALUE power_cache_get_power(int base, long n1, long *m1)
void rb_num_zerodiv(void)
VALUE rb_big2str(VALUE x, int base)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
#define RBIGNUM_DIGITS(b)
static VALUE bigand_int(VALUE x, long y)
static VALUE bigsub_int(VALUE x, long y0)
VALUE rb_str_resize(VALUE, long)
VALUE rb_num_coerce_bit(VALUE, VALUE, ID)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
VALUE rb_big_minus(VALUE x, VALUE y)
static VALUE rb_big_to_s(int argc, VALUE *argv, VALUE x)
#define REALLOC_N(var, type, n)
unsigned long rb_genrand_ulong_limited(unsigned long i)
VALUE rb_big_div(VALUE x, VALUE y)
VALUE rb_big_idiv(VALUE x, VALUE y)
#define MEMMOVE(p1, p2, type, n)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static VALUE bigmul1_balance(VALUE x, VALUE y)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
#define RBIGNUM_EMBED_LEN_MAX
static void bigadd_core(BDIGIT *xds, long xn, BDIGIT *yds, long yn, BDIGIT *zds, long zn)
VALUE rb_big_mul(VALUE x, VALUE y)
static VALUE rb_big_remainder(VALUE x, VALUE y)
static VALUE big_rshift(VALUE, unsigned long)
static VALUE big_sparse_p(VALUE x)
static VALUE bigmul1_karatsuba(VALUE x, VALUE y)
RUBY_EXTERN VALUE rb_cInteger
static VALUE power_cache_get_power0(int base, int i)
VALUE rb_num_coerce_relop(VALUE, VALUE, ID)
static VALUE rb_big_coerce(VALUE x, VALUE y)
static void bigrsh_bang(BDIGIT *xds, long xn, unsigned long shift)
static void shift(struct cparse_params *v, long act, VALUE tok, VALUE val)
static VALUE big_lshift(VALUE, unsigned long)
static VALUE bigsqr(VALUE x)
static VALUE rb_big_odd_p(VALUE num)
#define StringValueCStr(v)
static VALUE bignew_1(VALUE klass, long len, int sign)
static VALUE rb_big_to_f(VALUE x)
VALUE rb_usascii_str_new2(const char *)
VALUE rb_equal(VALUE, VALUE)
VALUE rb_big_uminus(VALUE x)
VALUE rb_str2inum(VALUE str, int base)
RUBY_EXTERN double round(double)
static void get2comp(VALUE x)
VALUE rb_big_norm(VALUE x)
void rb_thread_check_ints(void)
VALUE rb_big_lshift(VALUE x, VALUE y)
VALUE rb_big_or(VALUE xx, VALUE yy)
VALUE rb_big2str0(VALUE x, int base, int trim)
VALUE rb_uint2inum(VALUE n)
static VALUE rb_big_hash(VALUE x)
static VALUE bigadd(VALUE x, VALUE y, int sign)
static VALUE big_fdiv(VALUE x, VALUE y)
static long big2str_find_n1(VALUE x, int base)
VALUE rb_big_pow(VALUE x, VALUE y)
VALUE rb_int2big(SIGNED_VALUE n)
static unsigned int hash(const char *str, unsigned int len)
VALUE rb_integer_float_eq(VALUE x, VALUE y)
static VALUE big2ulong(VALUE x, const char *type, int check)
static VALUE bigmul1_normal(VALUE x, VALUE y)
#define assert(condition)
static int quad_buf_complement(char *buf, size_t len)
static double big2dbl(VALUE x)
RUBY_EXTERN VALUE rb_eFloatDomainError
#define RBIGNUM_SET_SIGN(b, sign)
VALUE rb_int2inum(SIGNED_VALUE n)
void rb_warning(const char *fmt,...)
#define RBIGNUM_EMBED_FLAG
static long big2str_karatsuba(VALUE x, int base, char *ptr, long n1, long len, long hbase, int trim)
void rb_big_2comp(VALUE x)
#define RBIGNUM_NEGATIVE_P(b)
VALUE rb_big_rshift(VALUE x, VALUE y)
VALUE rb_cstr_to_inum(const char *str, int base, int badcheck)
static int bigzero_p(VALUE x)
VALUE rb_usascii_str_new(const char *, long)
static VALUE bigsub(VALUE x, VALUE y)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void rb_quad_pack(char *buf, VALUE val)
void rb_warn(const char *fmt,...)
void rb_invalid_str(const char *str, const char *type)
static void big_split3(VALUE v, long n, volatile VALUE *p0, volatile VALUE *p1, volatile VALUE *p2)
static VALUE big_ge(VALUE x, VALUE y)
VALUE rb_cstr2inum(const char *str, int base)
void rb_cmperr(VALUE x, VALUE y)
static void bigdivmod(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
static int ones(register unsigned long x)
VALUE rb_num_coerce_cmp(VALUE, VALUE, ID)
#define KARATSUBA_MUL_DIGITS
static VALUE big_gt(VALUE x, VALUE y)