1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Using RB_BIGNUM_TYPE_P macro

This commit is contained in:
S-H-GAMELINKS 2021-09-03 20:50:12 +09:00 committed by Nobuyoshi Nakada
parent 56065f0686
commit 032534dbdf
Notes: git 2021-09-11 09:13:46 +09:00
15 changed files with 104 additions and 107 deletions

View file

@ -7803,7 +7803,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
n = 0; n = 0;
} }
} }
else if (RB_TYPE_P(e, T_BIGNUM)) else if (RB_BIGNUM_TYPE_P(e))
v = rb_big_plus(e, v); v = rb_big_plus(e, v);
else if (RB_TYPE_P(e, T_RATIONAL)) { else if (RB_TYPE_P(e, T_RATIONAL)) {
if (r == Qundef) if (r == Qundef)
@ -7840,7 +7840,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
x = RFLOAT_VALUE(e); x = RFLOAT_VALUE(e);
else if (FIXNUM_P(e)) else if (FIXNUM_P(e))
x = FIX2LONG(e); x = FIX2LONG(e);
else if (RB_TYPE_P(e, T_BIGNUM)) else if (RB_BIGNUM_TYPE_P(e))
x = rb_big2dbl(e); x = rb_big2dbl(e);
else if (RB_TYPE_P(e, T_RATIONAL)) else if (RB_TYPE_P(e, T_RATIONAL))
x = rb_num2dbl(e); x = rb_num2dbl(e);

View file

@ -42,8 +42,6 @@
#include "ruby/util.h" #include "ruby/util.h"
#include "ruby_assert.h" #include "ruby_assert.h"
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz"; const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
#ifndef SIZEOF_BDIGIT_DBL #ifndef SIZEOF_BDIGIT_DBL

View file

@ -1058,7 +1058,7 @@ rb_complex_pow(VALUE self, VALUE other)
if (k_numeric_p(other) && f_real_p(other)) { if (k_numeric_p(other) && f_real_p(other)) {
VALUE r, theta; VALUE r, theta;
if (RB_TYPE_P(other, T_BIGNUM)) if (RB_BIGNUM_TYPE_P(other))
rb_warn("in a**b, b may be too big"); rb_warn("in a**b, b may be too big");
r = f_abs(self); r = f_abs(self);

6
enum.c
View file

@ -848,7 +848,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
n = 0; n = 0;
} }
} }
else if (RB_TYPE_P(e, T_BIGNUM)) else if (RB_BIGNUM_TYPE_P(e))
v = rb_big_plus(e, v); v = rb_big_plus(e, v);
else else
goto not_integer; goto not_integer;
@ -4173,8 +4173,8 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
if (RTEST(rb_range_values(obj, &beg, &end, &excl))) { if (RTEST(rb_range_values(obj, &beg, &end, &excl))) {
if (!memo.block_given && !memo.float_value && if (!memo.block_given && !memo.float_value &&
(FIXNUM_P(beg) || RB_TYPE_P(beg, T_BIGNUM)) && (FIXNUM_P(beg) || RB_BIGNUM_TYPE_P(beg)) &&
(FIXNUM_P(end) || RB_TYPE_P(end, T_BIGNUM))) { (FIXNUM_P(end) || RB_BIGNUM_TYPE_P(end))) {
return int_range_sum(beg, end, excl, memo.v); return int_range_sum(beg, end, excl, memo.v);
} }
} }

4
gc.c
View file

@ -3417,7 +3417,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
static int static int
object_id_cmp(st_data_t x, st_data_t y) object_id_cmp(st_data_t x, st_data_t y)
{ {
if (RB_TYPE_P(x, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(x)) {
return !rb_big_eql(x, y); return !rb_big_eql(x, y);
} }
else { else {
@ -3428,7 +3428,7 @@ object_id_cmp(st_data_t x, st_data_t y)
static st_index_t static st_index_t
object_id_hash(st_data_t n) object_id_hash(st_data_t n)
{ {
if (RB_TYPE_P(n, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(n)) {
return FIX2LONG(rb_big_hash(n)); return FIX2LONG(rb_big_hash(n));
} }
else { else {

2
hash.c
View file

@ -132,7 +132,7 @@ rb_hash(VALUE obj)
} }
while (!FIXNUM_P(hval)) { while (!FIXNUM_P(hval)) {
if (RB_TYPE_P(hval, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(hval)) {
int sign; int sign;
unsigned long ul; unsigned long ul;
sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0, sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0,

View file

@ -104,5 +104,6 @@ RUBY_SYMBOL_EXPORT_END
#define bp() ruby_debug_breakpoint() #define bp() ruby_debug_breakpoint()
#define RBOOL(v) ((v) ? Qtrue : Qfalse) #define RBOOL(v) ((v) ? Qtrue : Qfalse)
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
#endif /* RUBY_INTERNAL_H */ #endif /* RUBY_INTERNAL_H */

2
io.c
View file

@ -4543,7 +4543,7 @@ rb_io_ungetc(VALUE io, VALUE c)
if (FIXNUM_P(c)) { if (FIXNUM_P(c)) {
c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr)); c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr));
} }
else if (RB_TYPE_P(c, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(c)) {
c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr)); c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr));
} }
else { else {

2
math.c
View file

@ -26,8 +26,6 @@
#include "internal/object.h" #include "internal/object.h"
#include "internal/vm.h" #include "internal/vm.h"
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
VALUE rb_mMath; VALUE rb_mMath;
VALUE rb_eMathDomainError; VALUE rb_eMathDomainError;

158
numeric.c
View file

@ -262,7 +262,7 @@ rb_num_to_uint(VALUE val, unsigned int *ret)
return 0; return 0;
} }
if (RB_TYPE_P(val, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(val)) {
if (BIGNUM_NEGATIVE_P(val)) return NUMERR_NEGATIVE; if (BIGNUM_NEGATIVE_P(val)) return NUMERR_NEGATIVE;
#if SIZEOF_INT < SIZEOF_LONG #if SIZEOF_INT < SIZEOF_LONG
/* long is 64bit */ /* long is 64bit */
@ -285,7 +285,7 @@ int_pos_p(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return FIXNUM_POSITIVE_P(num); return FIXNUM_POSITIVE_P(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return BIGNUM_POSITIVE_P(num); return BIGNUM_POSITIVE_P(num);
} }
rb_raise(rb_eTypeError, "not an Integer"); rb_raise(rb_eTypeError, "not an Integer");
@ -297,7 +297,7 @@ int_neg_p(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return FIXNUM_NEGATIVE_P(num); return FIXNUM_NEGATIVE_P(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return BIGNUM_NEGATIVE_P(num); return BIGNUM_NEGATIVE_P(num);
} }
rb_raise(rb_eTypeError, "not an Integer"); rb_raise(rb_eTypeError, "not an Integer");
@ -760,7 +760,7 @@ int_zero_p(VALUE num)
} }
} }
else { else {
assert(RB_TYPE_P(num, T_BIGNUM)); assert(RB_BIGNUM_TYPE_P(num));
if (rb_bigzero_p(num)) { if (rb_bigzero_p(num)) {
/* this should not happen usually */ /* this should not happen usually */
return Qtrue; return Qtrue;
@ -830,7 +830,7 @@ num_positive_p(VALUE num)
if (method_basic_p(rb_cInteger)) if (method_basic_p(rb_cInteger))
return RBOOL((SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0)); return RBOOL((SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0));
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
if (method_basic_p(rb_cInteger)) if (method_basic_p(rb_cInteger))
return RBOOL(BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num)); return RBOOL(BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num));
} }
@ -997,7 +997,7 @@ rb_float_plus(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) { if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y)); return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y));
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y)); return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1021,7 +1021,7 @@ rb_float_minus(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) { if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y)); return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y));
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y)); return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1045,7 +1045,7 @@ rb_float_mul(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) { if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y)); return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y)); return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1097,7 +1097,7 @@ rb_float_div(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) { if (RB_TYPE_P(y, T_FIXNUM)) {
den = FIX2LONG(y); den = FIX2LONG(y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
den = rb_big2dbl(y); den = rb_big2dbl(y);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1195,7 +1195,7 @@ flo_mod(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) { if (RB_TYPE_P(y, T_FIXNUM)) {
fy = (double)FIX2LONG(y); fy = (double)FIX2LONG(y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
fy = rb_big2dbl(y); fy = rb_big2dbl(y);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1235,7 +1235,7 @@ flo_divmod(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) { if (RB_TYPE_P(y, T_FIXNUM)) {
fy = (double)FIX2LONG(y); fy = (double)FIX2LONG(y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
fy = rb_big2dbl(y); fy = rb_big2dbl(y);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1271,7 +1271,7 @@ rb_float_pow(VALUE x, VALUE y)
dx = RFLOAT_VALUE(x); dx = RFLOAT_VALUE(x);
dy = (double)FIX2LONG(y); dy = (double)FIX2LONG(y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
dx = RFLOAT_VALUE(x); dx = RFLOAT_VALUE(x);
dy = rb_big2dbl(y); dy = rb_big2dbl(y);
} }
@ -1304,7 +1304,7 @@ num_eql(VALUE x, VALUE y)
{ {
if (TYPE(x) != TYPE(y)) return Qfalse; if (TYPE(x) != TYPE(y)) return Qfalse;
if (RB_TYPE_P(x, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_eql(x, y); return rb_big_eql(x, y);
} }
@ -1352,7 +1352,7 @@ rb_float_equal(VALUE x, VALUE y)
{ {
volatile double a, b; volatile double a, b;
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
return rb_integer_float_eq(y, x); return rb_integer_float_eq(y, x);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -1427,7 +1427,7 @@ flo_cmp(VALUE x, VALUE y)
a = RFLOAT_VALUE(x); a = RFLOAT_VALUE(x);
if (isnan(a)) return Qnil; if (isnan(a)) return Qnil;
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x); VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel)) if (FIXNUM_P(rel))
return LONG2FIX(-FIX2LONG(rel)); return LONG2FIX(-FIX2LONG(rel));
@ -1473,7 +1473,7 @@ rb_float_gt(VALUE x, VALUE y)
double a, b; double a, b;
a = RFLOAT_VALUE(x); a = RFLOAT_VALUE(x);
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x); VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel)) if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) > 0); return RBOOL(-FIX2LONG(rel) > 0);
@ -1510,7 +1510,7 @@ flo_ge(VALUE x, VALUE y)
double a, b; double a, b;
a = RFLOAT_VALUE(x); a = RFLOAT_VALUE(x);
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x); VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel)) if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) >= 0); return RBOOL(-FIX2LONG(rel) >= 0);
@ -1547,7 +1547,7 @@ flo_lt(VALUE x, VALUE y)
double a, b; double a, b;
a = RFLOAT_VALUE(x); a = RFLOAT_VALUE(x);
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x); VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel)) if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) < 0); return RBOOL(-FIX2LONG(rel) < 0);
@ -1584,7 +1584,7 @@ flo_le(VALUE x, VALUE y)
double a, b; double a, b;
a = RFLOAT_VALUE(x); a = RFLOAT_VALUE(x);
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) { if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x); VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel)) if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) <= 0); return RBOOL(-FIX2LONG(rel) <= 0);
@ -1980,7 +1980,7 @@ int_round_zero_p(VALUE num, int ndigits)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
bytes = sizeof(long); bytes = sizeof(long);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
bytes = rb_big_size(num); bytes = rb_big_size(num);
} }
else { else {
@ -2532,7 +2532,7 @@ num_step_negative_p(VALUE num)
if (method_basic_p(rb_cInteger)) if (method_basic_p(rb_cInteger))
return (SIGNED_VALUE)num < 0; return (SIGNED_VALUE)num < 0;
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
if (method_basic_p(rb_cInteger)) if (method_basic_p(rb_cInteger))
return BIGNUM_NEGATIVE_P(num); return BIGNUM_NEGATIVE_P(num);
} }
@ -2791,7 +2791,7 @@ rb_num2long(VALUE val)
FLOAT_OUT_OF_RANGE(val, "integer"); FLOAT_OUT_OF_RANGE(val, "integer");
} }
} }
else if (RB_TYPE_P(val, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2long(val); return rb_big2long(val);
} }
else { else {
@ -2827,7 +2827,7 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
FLOAT_OUT_OF_RANGE(val, "integer"); FLOAT_OUT_OF_RANGE(val, "integer");
} }
} }
else if (RB_TYPE_P(val, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(val)) {
{ {
unsigned long ul = rb_big2ulong(val); unsigned long ul = rb_big2ulong(val);
if (wrap_p) if (wrap_p)
@ -3062,7 +3062,7 @@ rb_num2ll(VALUE val)
FLOAT_OUT_OF_RANGE(val, "long long"); FLOAT_OUT_OF_RANGE(val, "long long");
} }
} }
else if (RB_TYPE_P(val, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ll(val); return rb_big2ll(val);
} }
else if (RB_TYPE_P(val, T_STRING)) { else if (RB_TYPE_P(val, T_STRING)) {
@ -3096,7 +3096,7 @@ rb_num2ull(VALUE val)
FLOAT_OUT_OF_RANGE(val, "unsigned long long"); FLOAT_OUT_OF_RANGE(val, "unsigned long long");
} }
} }
else if (RB_TYPE_P(val, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ull(val); return rb_big2ull(val);
} }
else if (RB_TYPE_P(val, T_STRING)) { else if (RB_TYPE_P(val, T_STRING)) {
@ -3128,7 +3128,7 @@ rb_int_odd_p(VALUE num)
return RBOOL(num & 2); return RBOOL(num & 2);
} }
else { else {
assert(RB_TYPE_P(num, T_BIGNUM)); assert(RB_BIGNUM_TYPE_P(num));
return rb_big_odd_p(num); return rb_big_odd_p(num);
} }
} }
@ -3140,7 +3140,7 @@ int_even_p(VALUE num)
return RBOOL((num & 2) == 0); return RBOOL((num & 2) == 0);
} }
else { else {
assert(RB_TYPE_P(num, T_BIGNUM)); assert(RB_BIGNUM_TYPE_P(num));
return rb_big_even_p(num); return rb_big_even_p(num);
} }
} }
@ -3216,7 +3216,7 @@ rb_int_succ(VALUE num)
long i = FIX2LONG(num) + 1; long i = FIX2LONG(num) + 1;
return LONG2NUM(i); return LONG2NUM(i);
} }
if (RB_TYPE_P(num, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_plus(num, INT2FIX(1)); return rb_big_plus(num, INT2FIX(1));
} }
return num_funcall1(num, '+', INT2FIX(1)); return num_funcall1(num, '+', INT2FIX(1));
@ -3242,7 +3242,7 @@ rb_int_pred(VALUE num)
long i = FIX2LONG(num) - 1; long i = FIX2LONG(num) - 1;
return LONG2NUM(i); return LONG2NUM(i);
} }
if (RB_TYPE_P(num, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_minus(num, INT2FIX(1)); return rb_big_minus(num, INT2FIX(1));
} }
return num_funcall1(num, '-', INT2FIX(1)); return num_funcall1(num, '-', INT2FIX(1));
@ -3345,7 +3345,7 @@ rb_int_uminus(VALUE num)
return fix_uminus(num); return fix_uminus(num);
} }
else { else {
assert(RB_TYPE_P(num, T_BIGNUM)); assert(RB_BIGNUM_TYPE_P(num));
return rb_big_uminus(num); return rb_big_uminus(num);
} }
} }
@ -3427,7 +3427,7 @@ rb_int2str(VALUE x, int base)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return rb_fix2str(x, base); return rb_fix2str(x, base);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big2str(x, base); return rb_big2str(x, base);
} }
@ -3449,7 +3449,7 @@ fix_plus(VALUE x, VALUE y)
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return rb_fix_plus_fix(x, y); return rb_fix_plus_fix(x, y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_plus(y, x); return rb_big_plus(y, x);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -3475,7 +3475,7 @@ rb_int_plus(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_plus(x, y); return fix_plus(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_plus(x, y); return rb_big_plus(x, y);
} }
return rb_num_coerce_bin(x, y, '+'); return rb_num_coerce_bin(x, y, '+');
@ -3496,7 +3496,7 @@ fix_minus(VALUE x, VALUE y)
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return rb_fix_minus_fix(x, y); return rb_fix_minus_fix(x, y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x)); x = rb_int2big(FIX2LONG(x));
return rb_big_minus(x, y); return rb_big_minus(x, y);
} }
@ -3514,7 +3514,7 @@ rb_int_minus(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_minus(x, y); return fix_minus(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_minus(x, y); return rb_big_minus(x, y);
} }
return rb_num_coerce_bin(x, y, '-'); return rb_num_coerce_bin(x, y, '-');
@ -3540,7 +3540,7 @@ fix_mul(VALUE x, VALUE y)
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return rb_fix_mul_fix(x, y); return rb_fix_mul_fix(x, y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
switch (x) { switch (x) {
case INT2FIX(0): return x; case INT2FIX(0): return x;
case INT2FIX(1): return y; case INT2FIX(1): return y;
@ -3564,7 +3564,7 @@ rb_int_mul(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_mul(x, y); return fix_mul(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_mul(x, y); return rb_big_mul(x, y);
} }
return rb_num_coerce_bin(x, y, '*'); return rb_num_coerce_bin(x, y, '*');
@ -3576,7 +3576,7 @@ fix_fdiv_double(VALUE x, VALUE y)
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return double_div_double(FIX2LONG(x), FIX2LONG(y)); return double_div_double(FIX2LONG(x), FIX2LONG(y));
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_fdiv_double(rb_int2big(FIX2LONG(x)), y); return rb_big_fdiv_double(rb_int2big(FIX2LONG(x)), y);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -3600,7 +3600,7 @@ rb_int_fdiv_double(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_fdiv_double(x, y); return fix_fdiv_double(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_fdiv_double(x, y); return rb_big_fdiv_double(x, y);
} }
else { else {
@ -3645,7 +3645,7 @@ fix_divide(VALUE x, VALUE y, ID op)
if (FIXNUM_ZERO_P(y)) rb_num_zerodiv(); if (FIXNUM_ZERO_P(y)) rb_num_zerodiv();
return rb_fix_div_fix(x, y); return rb_fix_div_fix(x, y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x)); x = rb_int2big(FIX2LONG(x));
return rb_big_div(x, y); return rb_big_div(x, y);
} }
@ -3681,7 +3681,7 @@ rb_int_div(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_div(x, y); return fix_div(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_div(x, y); return rb_big_div(x, y);
} }
return Qnil; return Qnil;
@ -3708,7 +3708,7 @@ rb_int_idiv(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_idiv(x, y); return fix_idiv(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_idiv(x, y); return rb_big_idiv(x, y);
} }
return num_div(x, y); return num_div(x, y);
@ -3733,7 +3733,7 @@ fix_mod(VALUE x, VALUE y)
if (FIXNUM_ZERO_P(y)) rb_num_zerodiv(); if (FIXNUM_ZERO_P(y)) rb_num_zerodiv();
return rb_fix_mod_fix(x, y); return rb_fix_mod_fix(x, y);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x)); x = rb_int2big(FIX2LONG(x));
return rb_big_modulo(x, y); return rb_big_modulo(x, y);
} }
@ -3751,7 +3751,7 @@ rb_int_modulo(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_mod(x, y); return fix_mod(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_modulo(x, y); return rb_big_modulo(x, y);
} }
return num_modulo(x, y); return num_modulo(x, y);
@ -3780,7 +3780,7 @@ int_remainder(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return num_remainder(x, y); return num_remainder(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_remainder(x, y); return rb_big_remainder(x, y);
} }
return Qnil; return Qnil;
@ -3802,7 +3802,7 @@ fix_divmod(VALUE x, VALUE y)
rb_fix_divmod_fix(x, y, &div, &mod); rb_fix_divmod_fix(x, y, &div, &mod);
return rb_assoc_new(div, mod); return rb_assoc_new(div, mod);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x)); x = rb_int2big(FIX2LONG(x));
return rb_big_divmod(x, y); return rb_big_divmod(x, y);
} }
@ -3828,7 +3828,7 @@ rb_int_divmod(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_divmod(x, y); return fix_divmod(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_divmod(x, y); return rb_big_divmod(x, y);
} }
return Qnil; return Qnil;
@ -3936,7 +3936,7 @@ fix_pow(VALUE x, VALUE y)
if (a == 0) return INT2FIX(0); if (a == 0) return INT2FIX(0);
return int_pow(a, b); return int_pow(a, b);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
if (a == 1) return INT2FIX(1); if (a == 1) return INT2FIX(1);
if (a == -1) return INT2FIX(int_even_p(y) ? 1 : -1); if (a == -1) return INT2FIX(int_even_p(y) ? 1 : -1);
if (BIGNUM_NEGATIVE_P(y)) return fix_pow_inverted(x, rb_big_uminus(y)); if (BIGNUM_NEGATIVE_P(y)) return fix_pow_inverted(x, rb_big_uminus(y));
@ -3966,7 +3966,7 @@ rb_int_pow(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_pow(x, y); return fix_pow(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_pow(x, y); return rb_big_pow(x, y);
} }
return Qnil; return Qnil;
@ -4008,7 +4008,7 @@ fix_equal(VALUE x, VALUE y)
{ {
if (x == y) return Qtrue; if (x == y) return Qtrue;
if (FIXNUM_P(y)) return Qfalse; if (FIXNUM_P(y)) return Qfalse;
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_eq(y, x); return rb_big_eq(y, x);
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -4025,7 +4025,7 @@ rb_int_equal(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_equal(x, y); return fix_equal(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_eq(x, y); return rb_big_eq(x, y);
} }
return Qnil; return Qnil;
@ -4052,7 +4052,7 @@ fix_cmp(VALUE x, VALUE y)
if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1); if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1);
return INT2FIX(-1); return INT2FIX(-1);
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
VALUE cmp = rb_big_cmp(y, x); VALUE cmp = rb_big_cmp(y, x);
switch (cmp) { switch (cmp) {
case INT2FIX(+1): return INT2FIX(-1); case INT2FIX(+1): return INT2FIX(-1);
@ -4074,7 +4074,7 @@ rb_int_cmp(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_cmp(x, y); return fix_cmp(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_cmp(x, y); return rb_big_cmp(x, y);
} }
else { else {
@ -4097,7 +4097,7 @@ fix_gt(VALUE x, VALUE y)
if (FIX2LONG(x) > FIX2LONG(y)) return Qtrue; if (FIX2LONG(x) > FIX2LONG(y)) return Qtrue;
return Qfalse; return Qfalse;
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) == INT2FIX(-1)); return RBOOL(rb_big_cmp(y, x) == INT2FIX(-1));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -4114,7 +4114,7 @@ rb_int_gt(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_gt(x, y); return fix_gt(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_gt(x, y); return rb_big_gt(x, y);
} }
return Qnil; return Qnil;
@ -4136,7 +4136,7 @@ fix_ge(VALUE x, VALUE y)
if (FIX2LONG(x) >= FIX2LONG(y)) return Qtrue; if (FIX2LONG(x) >= FIX2LONG(y)) return Qtrue;
return Qfalse; return Qfalse;
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) != INT2FIX(+1)); return RBOOL(rb_big_cmp(y, x) != INT2FIX(+1));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -4154,7 +4154,7 @@ rb_int_ge(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_ge(x, y); return fix_ge(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_ge(x, y); return rb_big_ge(x, y);
} }
return Qnil; return Qnil;
@ -4175,7 +4175,7 @@ fix_lt(VALUE x, VALUE y)
if (FIX2LONG(x) < FIX2LONG(y)) return Qtrue; if (FIX2LONG(x) < FIX2LONG(y)) return Qtrue;
return Qfalse; return Qfalse;
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) == INT2FIX(+1)); return RBOOL(rb_big_cmp(y, x) == INT2FIX(+1));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -4192,7 +4192,7 @@ int_lt(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_lt(x, y); return fix_lt(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_lt(x, y); return rb_big_lt(x, y);
} }
return Qnil; return Qnil;
@ -4214,7 +4214,7 @@ fix_le(VALUE x, VALUE y)
if (FIX2LONG(x) <= FIX2LONG(y)) return Qtrue; if (FIX2LONG(x) <= FIX2LONG(y)) return Qtrue;
return Qfalse; return Qfalse;
} }
else if (RB_TYPE_P(y, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) != INT2FIX(-1)); return RBOOL(rb_big_cmp(y, x) != INT2FIX(-1));
} }
else if (RB_TYPE_P(y, T_FLOAT)) { else if (RB_TYPE_P(y, T_FLOAT)) {
@ -4232,7 +4232,7 @@ int_le(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_le(x, y); return fix_le(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_le(x, y); return rb_big_le(x, y);
} }
return Qnil; return Qnil;
@ -4250,7 +4250,7 @@ rb_int_comp(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return fix_comp(num); return fix_comp(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_comp(num); return rb_big_comp(num);
} }
return Qnil; return Qnil;
@ -4301,7 +4301,7 @@ fix_and(VALUE x, VALUE y)
return LONG2NUM(val); return LONG2NUM(val);
} }
if (RB_TYPE_P(y, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_and(y, x); return rb_big_and(y, x);
} }
@ -4314,7 +4314,7 @@ rb_int_and(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_and(x, y); return fix_and(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_and(x, y); return rb_big_and(x, y);
} }
return Qnil; return Qnil;
@ -4336,7 +4336,7 @@ fix_or(VALUE x, VALUE y)
return LONG2NUM(val); return LONG2NUM(val);
} }
if (RB_TYPE_P(y, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_or(y, x); return rb_big_or(y, x);
} }
@ -4349,7 +4349,7 @@ int_or(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_or(x, y); return fix_or(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_or(x, y); return rb_big_or(x, y);
} }
return Qnil; return Qnil;
@ -4371,7 +4371,7 @@ fix_xor(VALUE x, VALUE y)
return LONG2NUM(val); return LONG2NUM(val);
} }
if (RB_TYPE_P(y, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_xor(y, x); return rb_big_xor(y, x);
} }
@ -4384,7 +4384,7 @@ int_xor(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return fix_xor(x, y); return fix_xor(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_xor(x, y); return rb_big_xor(x, y);
} }
return Qnil; return Qnil;
@ -4430,7 +4430,7 @@ rb_int_lshift(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return rb_fix_lshift(x, y); return rb_fix_lshift(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_lshift(x, y); return rb_big_lshift(x, y);
} }
return Qnil; return Qnil;
@ -4477,7 +4477,7 @@ rb_int_rshift(VALUE x, VALUE y)
if (FIXNUM_P(x)) { if (FIXNUM_P(x)) {
return rb_fix_rshift(x, y); return rb_fix_rshift(x, y);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_rshift(x, y); return rb_big_rshift(x, y);
} }
return Qnil; return Qnil;
@ -4578,7 +4578,7 @@ one_bit:
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return rb_fix_aref(num, arg); return rb_fix_aref(num, arg);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_aref(num, arg); return rb_big_aref(num, arg);
} }
return Qnil; return Qnil;
@ -4660,7 +4660,7 @@ int_to_f(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
val = (double)FIX2LONG(num); val = (double)FIX2LONG(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
val = rb_big2dbl(num); val = rb_big2dbl(num);
} }
else { else {
@ -4686,7 +4686,7 @@ rb_int_abs(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return fix_abs(num); return fix_abs(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_abs(num); return rb_big_abs(num);
} }
return Qnil; return Qnil;
@ -4704,7 +4704,7 @@ rb_int_size(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return fix_size(num); return fix_size(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_size_m(num); return rb_big_size_m(num);
} }
return Qnil; return Qnil;
@ -4725,7 +4725,7 @@ rb_int_bit_length(VALUE num)
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
return rb_fix_bit_length(num); return rb_fix_bit_length(num);
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_bit_length(num); return rb_big_bit_length(num);
} }
return Qnil; return Qnil;
@ -4782,12 +4782,12 @@ rb_int_digits_bigbase(VALUE num, VALUE base)
assert(!rb_num_negative_p(num)); assert(!rb_num_negative_p(num));
if (RB_TYPE_P(base, T_BIGNUM)) if (RB_BIGNUM_TYPE_P(base))
base = rb_big_norm(base); base = rb_big_norm(base);
if (FIXNUM_P(base) && FIX2LONG(base) < 2) if (FIXNUM_P(base) && FIX2LONG(base) < 2)
rb_raise(rb_eArgError, "invalid radix %ld", FIX2LONG(base)); rb_raise(rb_eArgError, "invalid radix %ld", FIX2LONG(base));
else if (RB_TYPE_P(base, T_BIGNUM) && BIGNUM_NEGATIVE_P(base)) else if (RB_BIGNUM_TYPE_P(base) && BIGNUM_NEGATIVE_P(base))
rb_raise(rb_eArgError, "negative radix"); rb_raise(rb_eArgError, "negative radix");
if (FIXNUM_P(base) && FIXNUM_P(num)) if (FIXNUM_P(base) && FIXNUM_P(num))
@ -4841,7 +4841,7 @@ rb_int_digits(int argc, VALUE *argv, VALUE num)
if (!RB_INTEGER_TYPE_P(base_value)) if (!RB_INTEGER_TYPE_P(base_value))
rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)", rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)",
rb_obj_classname(argv[0])); rb_obj_classname(argv[0]));
if (RB_TYPE_P(base_value, T_BIGNUM)) if (RB_BIGNUM_TYPE_P(base_value))
return rb_int_digits_bigbase(num, base_value); return rb_int_digits_bigbase(num, base_value);
base = FIX2LONG(base_value); base = FIX2LONG(base_value);
@ -4855,7 +4855,7 @@ rb_int_digits(int argc, VALUE *argv, VALUE num)
if (FIXNUM_P(num)) if (FIXNUM_P(num))
return rb_fix_digits(num, base); return rb_fix_digits(num, base);
else if (RB_TYPE_P(num, T_BIGNUM)) else if (RB_BIGNUM_TYPE_P(num))
return rb_int_digits_bigbase(num, LONG2FIX(base)); return rb_int_digits_bigbase(num, LONG2FIX(base));
return Qnil; return Qnil;

View file

@ -3425,7 +3425,7 @@ rb_str_to_dbl(VALUE str, int badcheck)
(FIXNUM_P(x) ? fix2dbl_without_to_f(x) : big2dbl_without_to_f(x)) (FIXNUM_P(x) ? fix2dbl_without_to_f(x) : big2dbl_without_to_f(x))
#define num2dbl_without_to_f(x) \ #define num2dbl_without_to_f(x) \
(FIXNUM_P(x) ? fix2dbl_without_to_f(x) : \ (FIXNUM_P(x) ? fix2dbl_without_to_f(x) : \
RB_TYPE_P(x, T_BIGNUM) ? big2dbl_without_to_f(x) : \ RB_BIGNUM_TYPE_P(x) ? big2dbl_without_to_f(x) : \
(Check_Type(x, T_FLOAT), RFLOAT_VALUE(x))) (Check_Type(x, T_FLOAT), RFLOAT_VALUE(x)))
static inline double static inline double
rat2dbl_without_to_f(VALUE x) rat2dbl_without_to_f(VALUE x)

View file

@ -199,7 +199,7 @@ f_minus_one_p(VALUE x)
if (RB_INTEGER_TYPE_P(x)) { if (RB_INTEGER_TYPE_P(x)) {
return x == LONG2FIX(-1); return x == LONG2FIX(-1);
} }
else if (RB_TYPE_P(x, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(x)) {
return Qfalse; return Qfalse;
} }
else if (RB_TYPE_P(x, T_RATIONAL)) { else if (RB_TYPE_P(x, T_RATIONAL)) {
@ -365,7 +365,7 @@ inline static VALUE
f_gcd(VALUE x, VALUE y) f_gcd(VALUE x, VALUE y)
{ {
#ifdef USE_GMP #ifdef USE_GMP
if (RB_TYPE_P(x, T_BIGNUM) && RB_TYPE_P(y, T_BIGNUM)) { if (RB_BIGNUM_TYPE_P(x) && RB_BIGNUM_TYPE_P(y)) {
size_t xn = BIGNUM_LEN(x); size_t xn = BIGNUM_LEN(x);
size_t yn = BIGNUM_LEN(y); size_t yn = BIGNUM_LEN(y);
if (GMP_GCD_DIGITS <= xn || GMP_GCD_DIGITS <= yn) if (GMP_GCD_DIGITS <= xn || GMP_GCD_DIGITS <= yn)
@ -1034,7 +1034,7 @@ rb_rational_pow(VALUE self, VALUE other)
return f_rational_new2(CLASS_OF(self), num, den); return f_rational_new2(CLASS_OF(self), num, den);
} }
} }
else if (RB_TYPE_P(other, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(other)) {
rb_warn("in a**b, b may be too big"); rb_warn("in a**b, b may be too big");
return rb_float_pow(nurat_to_f(self), other); return rb_float_pow(nurat_to_f(self), other);
} }

View file

@ -219,7 +219,7 @@ case_conv(char *s, ptrdiff_t i, int flags)
static VALUE static VALUE
format_value(VALUE val, int base) format_value(VALUE val, int base)
{ {
if (!RB_TYPE_P(val, T_BIGNUM)) if (!RB_BIGNUM_TYPE_P(val))
val = rb_Integer(val); val = rb_Integer(val);
return rb_big2str(val, base); return rb_big2str(val, base);
} }

View file

@ -5170,7 +5170,7 @@ recursive_check(VALUE list, VALUE obj, VALUE paired_obj_id)
#if SIZEOF_LONG == SIZEOF_VOIDP #if SIZEOF_LONG == SIZEOF_VOIDP
#define OBJ_ID_EQL(obj_id, other) ((obj_id) == (other)) #define OBJ_ID_EQL(obj_id, other) ((obj_id) == (other))
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
#define OBJ_ID_EQL(obj_id, other) (RB_TYPE_P((obj_id), T_BIGNUM) ? \ #define OBJ_ID_EQL(obj_id, other) (RB_BIGNUM_TYPE_P((obj_id)) ? \
rb_big_eql((obj_id), (other)) : ((obj_id) == (other))) rb_big_eql((obj_id), (other)) : ((obj_id) == (other)))
#endif #endif

16
time.c
View file

@ -87,7 +87,7 @@ cmp(VALUE x, VALUE y)
return 1; return 1;
return 0; return 0;
} }
if (RB_TYPE_P(x, T_BIGNUM)) return FIX2INT(rb_big_cmp(x, y)); if (RB_BIGNUM_TYPE_P(x)) return FIX2INT(rb_big_cmp(x, y));
return rb_cmpint(rb_funcall(x, idCmp, 1, y), x, y); return rb_cmpint(rb_funcall(x, idCmp, 1, y), x, y);
} }
@ -103,7 +103,7 @@ addv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) { if (FIXNUM_P(x) && FIXNUM_P(y)) {
return LONG2NUM(FIX2LONG(x) + FIX2LONG(y)); return LONG2NUM(FIX2LONG(x) + FIX2LONG(y));
} }
if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_plus(x, y); if (RB_BIGNUM_TYPE_P(x)) return rb_big_plus(x, y);
return rb_funcall(x, '+', 1, y); return rb_funcall(x, '+', 1, y);
} }
@ -113,7 +113,7 @@ subv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) { if (FIXNUM_P(x) && FIXNUM_P(y)) {
return LONG2NUM(FIX2LONG(x) - FIX2LONG(y)); return LONG2NUM(FIX2LONG(x) - FIX2LONG(y));
} }
if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_minus(x, y); if (RB_BIGNUM_TYPE_P(x)) return rb_big_minus(x, y);
return rb_funcall(x, '-', 1, y); return rb_funcall(x, '-', 1, y);
} }
@ -123,7 +123,7 @@ mulv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) { if (FIXNUM_P(x) && FIXNUM_P(y)) {
return rb_fix_mul_fix(x, y); return rb_fix_mul_fix(x, y);
} }
if (RB_TYPE_P(x, T_BIGNUM)) if (RB_BIGNUM_TYPE_P(x))
return rb_big_mul(x, y); return rb_big_mul(x, y);
return rb_funcall(x, '*', 1, y); return rb_funcall(x, '*', 1, y);
} }
@ -134,7 +134,7 @@ divv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) { if (FIXNUM_P(x) && FIXNUM_P(y)) {
return rb_fix_div_fix(x, y); return rb_fix_div_fix(x, y);
} }
if (RB_TYPE_P(x, T_BIGNUM)) if (RB_BIGNUM_TYPE_P(x))
return rb_big_div(x, y); return rb_big_div(x, y);
return rb_funcall(x, id_div, 1, y); return rb_funcall(x, id_div, 1, y);
} }
@ -146,7 +146,7 @@ modv(VALUE x, VALUE y)
if (FIX2LONG(y) == 0) rb_num_zerodiv(); if (FIX2LONG(y) == 0) rb_num_zerodiv();
if (FIXNUM_P(x)) return rb_fix_mod_fix(x, y); if (FIXNUM_P(x)) return rb_fix_mod_fix(x, y);
} }
if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_modulo(x, y); if (RB_BIGNUM_TYPE_P(x)) return rb_big_modulo(x, y);
return rb_funcall(x, '%', 1, y); return rb_funcall(x, '%', 1, y);
} }
@ -322,7 +322,7 @@ v2w(VALUE v)
if (FIXNUM_P(v)) { if (FIXNUM_P(v)) {
return WIDEVAL_WRAP((WIDEVALUE)(SIGNED_WIDEVALUE)(long)v); return WIDEVAL_WRAP((WIDEVALUE)(SIGNED_WIDEVALUE)(long)v);
} }
else if (RB_TYPE_P(v, T_BIGNUM) && else if (RB_BIGNUM_TYPE_P(v) &&
rb_absint_size(v, NULL) <= sizeof(WIDEVALUE)) { rb_absint_size(v, NULL) <= sizeof(WIDEVALUE)) {
return v2w_bignum(v); return v2w_bignum(v);
} }
@ -2575,7 +2575,7 @@ time_timespec(VALUE num, int interval)
} }
} }
} }
else if (RB_TYPE_P(num, T_BIGNUM)) { else if (RB_BIGNUM_TYPE_P(num)) {
t.tv_sec = NUM2TIMET(num); t.tv_sec = NUM2TIMET(num);
arg_range_check(t.tv_sec); arg_range_check(t.tv_sec);
t.tv_nsec = 0; t.tv_nsec = 0;