Ruby
2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)
|
Go to the documentation of this file.
37 #define DBL_MIN 2.2250738585072014e-308
40 #define DBL_MAX 1.7976931348623157e+308
43 #define DBL_MIN_EXP (-1021)
46 #define DBL_MAX_EXP 1024
48 #ifndef DBL_MIN_10_EXP
49 #define DBL_MIN_10_EXP (-307)
51 #ifndef DBL_MAX_10_EXP
52 #define DBL_MAX_10_EXP 308
58 #define DBL_MANT_DIG 53
61 #define DBL_EPSILON 2.2204460492503131e-16
64 #ifndef USE_RB_INFINITY
65 #elif !defined(WORDS_BIGENDIAN)
72 #elif !defined(WORDS_BIGENDIAN)
86 x =
f + (x -
f >= 0.5);
90 x =
f - (
f - x >= 0.5);
97 round_half_up(
double x,
double s)
102 if (s == 1.0)
return f;
104 if ((
double)((
f + 0.5) / s) <= x)
f += 1;
108 if ((
double)((
f - 0.5) / s) >= x)
f -= 1;
115 round_half_down(
double x,
double s)
117 double f, xs = x * s;
121 if ((
double)((
f - 0.5) / s) >= x)
f -= 1;
125 if ((
double)((
f + 0.5) / s) <= x)
f += 1;
132 round_half_even(
double x,
double s)
134 double f, d, xs = x * s;
141 else if (d == 0.5 || ((
double)((
f + 0.5) / s) <= x))
152 else if (d == 0.5 || ((
double)((
f - 0.5) / s) >= x))
163 static VALUE fix_lshift(
long,
unsigned long);
164 static VALUE fix_rshift(
long,
unsigned long);
165 static VALUE int_pow(
long x,
unsigned long y);
167 static int int_round_zero_p(
VALUE num,
int ndigits);
171 static int float_round_overflow(
int ndigits,
int binexp);
172 static int float_round_underflow(
int ndigits,
int binexp);
176 #define id_divmod idDivmod
177 #define id_to_i idTo_i
184 #ifndef RUBY_INTEGER_UNIFICATION
191 static ID id_to, id_by;
202 static ID round_kwds[1];
208 if (!round_kwds[0]) {
211 if (!
rb_get_kwargs(opts, round_kwds, 0, 1, &rounding))
goto noopt;
215 else if (
NIL_P(rounding)) {
246 #define NUMERR_TYPE 1
247 #define NUMERR_NEGATIVE 2
248 #define NUMERR_TOOLARGE 3
251 #if SIZEOF_INT < SIZEOF_LONG
255 *ret = (
unsigned int)
v;
261 #if SIZEOF_INT < SIZEOF_LONG
274 #define method_basic_p(klass) rb_method_basic_definition_p(klass, mid)
303 return int_pos_p(num);
309 return int_neg_p(num);
315 return rb_num_negative_int_p(num);
368 num_funcall_op_1_recursion(x, func, y);
377 args[0] = (
VALUE)func;
429 coerce_failed(*x, *y);
448 do_coerce(&x, &y,
TRUE);
455 if (do_coerce(&x, &y,
FALSE))
465 if (!do_coerce(&x, &y,
FALSE) ||
508 # define num_clone rb_immutable_obj_clone
524 # define num_dup num_uplus
552 num_imaginary(
VALUE num)
565 num_uminus(
VALUE num)
570 do_coerce(&zero, &num,
TRUE);
572 return num_funcall1(zero,
'-', num);
638 VALUE z = num_funcall1(x,
'%', y);
641 ((rb_num_negative_int_p(x) &&
642 rb_num_positive_int_p(y)) ||
643 (rb_num_positive_int_p(x) &&
644 rb_num_negative_int_p(y)))) {
707 num_real_p(
VALUE num)
745 if (rb_num_negative_int_p(num)) {
759 num_zero_p(
VALUE num)
792 num_nonzero_p(
VALUE num)
807 num_finite_p(
VALUE num)
820 num_infinite_p(
VALUE num)
837 num_to_int(
VALUE num)
839 return num_funcall0(num,
id_to_i);
850 num_positive_p(
VALUE num)
862 return rb_num_compare_with_zero(num, mid);
873 num_negative_p(
VALUE num)
875 return rb_num_negative_int_p(num) ?
Qtrue :
Qfalse;
899 flt->float_value = d;
922 int sign, decpt, digs;
925 static const char minf[] =
"-Infinity";
926 const int pos = (value > 0);
929 else if (
isnan(value))
932 p =
ruby_dtoa(value, 0, 0, &decpt, &sign, &e);
934 if ((digs = (
int)(e - p)) >= (
int)
sizeof(
buf)) digs = (
int)
sizeof(
buf) - 1;
959 else if (decpt > -4) {
1095 double_div_double(
double x,
double y)
1100 else if (x == 0.0) {
1104 double z =
signbit(y) ? -1.0 : 1.0;
1114 double ret = double_div_double(num, den);
1145 ret = double_div_double(num, den);
1160 return num_funcall1(x,
'/', y);
1164 flodivmod(
double x,
double y,
double *divp,
double *modp)
1170 if (modp) *modp = y;
1171 if (divp) *divp = y;
1197 if (modp) *modp =
mod;
1198 if (divp) *divp =
div;
1210 flodivmod(x, y, 0, &
mod);
1268 volatile VALUE a, b;
1312 if (dx < 0 && dy !=
round(dy))
1355 if (x == y)
return INT2FIX(0);
1363 if (x == y)
return Qtrue;
1364 result = num_funcall1(y,
id_eq, x);
1385 volatile double a, b;
1392 #if defined(_MSC_VER) && _MSC_VER < 1300
1397 return num_equal(x, y);
1400 #if defined(_MSC_VER) && _MSC_VER < 1300
1406 #define flo_eq rb_float_equal
1407 static VALUE rb_dbl_hash(
double d);
1425 rb_dbl_hash(
double d)
1434 if (a == b)
return INT2FIX(0);
1436 if (a < b)
return INT2FIX(-1);
1475 j = (a > 0.0) ? (j > 0 ? 0 : +1) : (j < 0 ? 0 : -1);
1478 if (a > 0.0)
return INT2FIX(1);
1489 return NUM2INT(flo_cmp(x, y));
1516 #if defined(_MSC_VER) && _MSC_VER < 1300
1523 #if defined(_MSC_VER) && _MSC_VER < 1300
1553 #if defined(_MSC_VER) && _MSC_VER < 1300
1560 #if defined(_MSC_VER) && _MSC_VER < 1300
1590 #if defined(_MSC_VER) && _MSC_VER < 1300
1597 #if defined(_MSC_VER) && _MSC_VER < 1300
1627 #if defined(_MSC_VER) && _MSC_VER < 1300
1634 #if defined(_MSC_VER) && _MSC_VER < 1300
1659 #if defined(_MSC_VER) && _MSC_VER < 1300
1668 #define flo_eql rb_float_eql
1712 flo_zero_p(
VALUE num)
1730 flo_is_nan_p(
VALUE num)
1755 return INT2FIX( value < 0 ? -1 : 1 );
1774 #ifdef HAVE_ISFINITE
1838 flo_next_float(
VALUE vx)
1889 flo_prev_float(
VALUE vx)
1946 if (number == 0.0) {
1951 frexp(number, &binexp);
1952 if (float_round_overflow(ndigits, binexp))
return num;
1953 if (number > 0.0 && float_round_underflow(ndigits, binexp))
1955 f =
pow(10, ndigits);
1960 num = dbl2ival(
floor(number));
2022 if (number == 0.0) {
2027 frexp(number, &binexp);
2028 if (float_round_overflow(ndigits, binexp))
return num;
2029 if (number < 0.0 && float_round_underflow(ndigits, binexp))
2031 f =
pow(10, ndigits);
2036 num = dbl2ival(
ceil(number));
2043 int_round_zero_p(
VALUE num,
int ndigits)
2049 bytes =
sizeof(
long);
2057 return (-0.415241 * ndigits - 0.125 > bytes);
2064 if ((z * y - x) * 2 == y) {
2073 return (x + y / 2) / y * y;
2079 return (x + y / 2 - 1) / y * y;
2091 return int_pos_p(num);
2097 return int_neg_p(num);
2108 if (int_round_zero_p(num, ndigits)) {
2112 f = int_pow(10, -ndigits);
2141 if (int_round_zero_p(num, ndigits))
2143 f = int_pow(10, -ndigits);
2147 if (
neg) x = -x + y - 1;
2164 if (int_round_zero_p(num, ndigits))
2166 f = int_pow(10, -ndigits);
2189 if (int_round_zero_p(num, ndigits))
2191 f = int_pow(10, -ndigits);
2205 if (int_neg_p(num)) {
2268 double number,
f, x;
2278 if (number == 0.0) {
2282 return rb_int_round(flo_to_i(num), ndigits, mode);
2290 frexp(number, &binexp);
2291 if (float_round_overflow(ndigits, binexp))
return num;
2292 if (float_round_underflow(ndigits, binexp))
return DBL2NUM(0);
2293 f =
pow(10, ndigits);
2301 float_round_overflow(
int ndigits,
int binexp)
2322 if (ndigits >= float_dig - (binexp > 0 ? binexp / 4 : binexp / 3 - 1)) {
2329 float_round_underflow(
int ndigits,
int binexp)
2331 if (ndigits < - (binexp > 0 ? binexp / 3 + 1 : binexp / 4)) {
2406 flo_positive_p(
VALUE num)
2420 flo_negative_p(
VALUE num)
2503 n= (end - beg)/unit;
2506 return unit > 0 ? beg <= end : beg >= end;
2537 else if (unit == 0) {
2543 for (
i=0;
i<
n;
i++) {
2544 double d =
i*unit+beg;
2545 if (unit >= 0 ? end < d : d < end) d = end;
2589 case -1: cmp =
'<';
break;
2601 num_step_negative_p(
VALUE num)
2618 coerce_failed(num,
INT2FIX(0));
2635 if (values[0] !=
Qundef) {
2639 if (values[1] !=
Qundef) {
2649 num_step_check_fix_args(
int argc,
VALUE *to,
VALUE *step,
VALUE by,
int fix_nil,
int allow_zero_step)
2667 desc = num_step_negative_p(*step);
2668 if (fix_nil &&
NIL_P(*to)) {
2678 argc = num_step_extract_args(
argc,
argv, to, step, &by);
2679 return num_step_check_fix_args(
argc, to, step, by, fix_nil, allow_zero_step);
2759 num_step_extract_args(
argc,
argv, &to, &step, &by);
2769 num_step_size, from, to, step,
FALSE);
2797 for (;
i >= end;
i += diff)
2801 for (;
i <= end;
i += diff)
2814 ID cmp = desc ?
'<' :
'>';
2824 out_of_range_float(
char (*pbuf)[24],
VALUE val)
2826 char *
const buf = *pbuf;
2830 if ((s =
strchr(
buf,
' ')) != 0) *s =
'\0';
2834 #define FLOAT_OUT_OF_RANGE(val, type) do { \
2836 rb_raise(rb_eRangeError, "float %s out of range of "type, \
2837 out_of_range_float(&buf, (val))); \
2840 #define LONG_MIN_MINUS_ONE ((double)LONG_MIN-1)
2841 #define LONG_MAX_PLUS_ONE (2*(double)(LONG_MAX/2+1))
2842 #define ULONG_MAX_PLUS_ONE (2*(double)(ULONG_MAX/2+1))
2843 #define LONG_MIN_MINUS_ONE_IS_LESS_THAN(n) \
2844 (LONG_MIN_MINUS_ONE == (double)LONG_MIN ? \
2846 LONG_MIN_MINUS_ONE < (n))
2876 static unsigned long
2877 rb_num2ulong_internal(
VALUE val,
int *wrap_p)
2888 return (
unsigned long)l;
2894 *wrap_p = d <= -1.0;
2896 return (
unsigned long)d;
2897 return (
unsigned long)(
long)d;
2920 return rb_num2ulong_internal(val,
NULL);
2923 #if SIZEOF_INT < SIZEOF_LONG
2928 num, num < 0 ?
"small" :
"big");
2934 if ((
long)(
int)num != num) {
2940 check_uint(
unsigned long num,
int sign)
2944 if (num < (
unsigned long)
INT_MIN)
2973 rb_num2uint(
VALUE val)
2976 unsigned long num = rb_num2ulong_internal(val, &wrap);
2978 check_uint(num, wrap);
2983 rb_fix2uint(
VALUE val)
2988 return rb_num2uint(val);
2992 check_uint(num, rb_num_negative_int_p(val));
3014 num, num < 0 ?
"small" :
"big");
3018 check_short(
long num)
3020 if ((
long)(
short)num != num) {
3021 rb_out_of_short(num);
3026 check_ushort(
unsigned long num,
int sign)
3062 unsigned long num = rb_num2ulong_internal(val, &wrap);
3064 check_ushort(num, wrap);
3078 check_ushort(num, rb_num_negative_int_p(val));
3097 #define LLONG_MIN_MINUS_ONE ((double)LLONG_MIN-1)
3098 #define LLONG_MAX_PLUS_ONE (2*(double)(LLONG_MAX/2+1))
3099 #define ULLONG_MAX_PLUS_ONE (2*(double)(ULLONG_MAX/2+1))
3101 #define ULLONG_MAX ((unsigned LONG_LONG)LLONG_MAX*2+1)
3103 #define LLONG_MIN_MINUS_ONE_IS_LESS_THAN(n) \
3104 (LLONG_MIN_MINUS_ONE == (double)LLONG_MIN ? \
3106 LLONG_MIN_MINUS_ONE < (n))
3109 rb_num2ll(
VALUE val)
3119 if (d < LLONG_MAX_PLUS_ONE && (LLONG_MIN_MINUS_ONE_IS_LESS_THAN(d))) {
3141 rb_num2ull(
VALUE val)
3151 if (d < ULLONG_MAX_PLUS_ONE && LLONG_MIN_MINUS_ONE_IS_LESS_THAN(d)) {
3209 int_int_p(
VALUE num)
3246 int_even_p(
VALUE num)
3249 if ((num & 2) == 0) {
3330 return num_funcall1(num,
'+',
INT2FIX(1));
3333 #define int_succ rb_int_succ
3347 rb_int_pred(
VALUE num)
3356 return num_funcall1(num,
'-',
INT2FIX(1));
3359 #define int_pred rb_int_pred
3473 fix_uminus(
VALUE num)
3482 return fix_uminus(num);
3487 return num_funcall0(num,
idUMinus);
3515 if (base < 2 || 36 < base) {
3518 #if SIZEOF_LONG < SIZEOF_VOIDP
3519 # if SIZEOF_VOIDP == SIZEOF_LONG_LONG
3520 if ((val >= 0 && (x & 0xFFFFFFFF00000000ull)) ||
3521 (val < 0 && (x & 0xFFFFFFFF00000000ull) != 0xFFFFFFFF00000000ull)) {
3522 rb_bug(
"Unnormalized Fixnum value %p", (
void *)x);
3533 u = 1 + (
unsigned long)(-(val + 1));
3541 }
while (u /= base);
3587 return rb_fix_plus_fix(x, y);
3606 return fix_plus(x, y);
3613 return fix_plus(x, y);
3634 return rb_fix_minus_fix(x, y);
3652 return fix_minus(x, y);
3661 #define SQRT_LONG_MAX HALF_LONG_MSB
3663 #define FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))
3678 return rb_fix_mul_fix(x, y);
3702 return fix_mul(x, y);
3738 return fix_fdiv_double(x, y);
3783 return rb_fix_div_fix(x, y);
3797 v = fix_divide(x, y,
'/');
3798 return flo_floor(0, 0,
v);
3812 return fix_divide(x, y,
'/');
3819 return fix_div(x, y);
3839 return fix_divide(x, y,
id_div);
3846 return fix_idiv(x, y);
3851 return num_div(x, y);
3871 return rb_fix_mod_fix(x, y);
3889 return fix_mod(x, y);
3894 return num_modulo(x, y);
3918 return num_remainder(x, y);
3939 rb_fix_divmod_fix(x, y, &
div, &
mod);
3949 volatile VALUE a, b;
3966 return fix_divmod(x, y);
3994 int_pow(
long x,
unsigned long y)
3999 if (y == 0)
return INT2FIX(1);
4008 while (y % 2 == 0) {
4035 return int_pow(x, y);
4046 if (a == 1)
return INT2FIX(1);
4059 if (b == 0)
return INT2FIX(1);
4060 if (b == 1)
return x;
4065 return int_pow(a, b);
4068 if (a == 1)
return INT2FIX(1);
4070 if (int_even_p(y))
return INT2FIX(1);
4083 if (a == 0)
return INT2FIX(0);
4089 if (dy == 0.0)
return DBL2NUM(1.0);
4093 if (a == 1)
return DBL2NUM(1.0);
4095 if (a < 0 && dy !=
round(dy))
4109 return fix_pow(x, y);
4121 if (!
NIL_P(z))
return z;
4149 if (x == y)
return Qtrue;
4158 return num_equal(x, y);
4166 return fix_equal(x, y);
4190 if (x == y)
return INT2FIX(0);
4215 return fix_cmp(x, y);
4255 return fix_gt(x, y);
4295 return fix_ge(x, y);
4333 return fix_lt(x, y);
4373 return fix_le(x, y);
4406 return fix_comp(num);
4420 num_funcall_op_1_recursion(x, func, y);
4430 args[0] = (
VALUE)func;
4433 do_coerce(&args[1], &args[2],
TRUE);
4435 args[2], args[1], (
VALUE)args);
4438 coerce_failed(x, y);
4470 return fix_and(x, y);
4505 return fix_or(x, y);
4540 return fix_xor(x, y);
4567 return fix_rshift(val, (
unsigned long)-width);
4568 return fix_lshift(val, width);
4572 fix_lshift(
long val,
unsigned long width)
4586 return rb_fix_lshift(x, y);
4612 if (
i == 0)
return x;
4614 return fix_lshift(val, (
unsigned long)-
i);
4615 return fix_rshift(val,
i);
4619 fix_rshift(
long val,
unsigned long i)
4622 if (val < 0)
return INT2FIX(-1);
4633 return rb_fix_rshift(x, y);
4660 if (val < 0)
return INT2FIX(1);
4694 VALUE orig_num = num, beg, end;
4700 if (!
RTEST(num_negative_p(end))) {
4714 num = rb_int_rshift(num, beg);
4716 int cmp = compare_indexes(beg, end);
4717 if (!
NIL_P(end) && cmp < 0) {
4723 else if (cmp == 0) {
4745 num = rb_int_rshift(num, beg);
4794 return int_aref2(num,
argv[0],
argv[1]);
4796 return int_aref1(num,
argv[0]);
4858 return fix_abs(num);
4892 return fix_size(num);
4946 rb_fix_bit_length(
VALUE fix)
4955 rb_int_bit_length(
VALUE num)
4958 return rb_fix_bit_length(num);
4987 rb_fix_digits(
VALUE fix,
long base)
5026 return rb_fix_digits(num,
FIX2LONG(base));
5056 return rb_int_digits_bigbase(num, base_value);
5068 return rb_fix_digits(num, base);
5070 return rb_int_digits_bigbase(num,
LONG2FIX(base));
5192 int_dotimes(
VALUE num)
5200 for (
i=0;
i<end;
i++) {
5261 return rb_int_round(num, ndigits, mode);
5360 #define DEFINE_INT_SQRT(rettype, prefix, argtype) \
5362 prefix##_isqrt(argtype n) \
5364 if (!argtype##_IN_DOUBLE_P(n)) { \
5365 unsigned int b = bit_length(n); \
5367 rettype x = (rettype)(n >> (b/2+1)); \
5368 x |= ((rettype)1LU << (b-1)/2); \
5369 while ((t = n/x) < (argtype)x) x = (rettype)((x + t) >> 1); \
5372 return (rettype)sqrt(argtype##_TO_DOUBLE(n)); \
5375 #if SIZEOF_LONG*CHAR_BIT > DBL_MANT_DIG
5376 # define RB_ULONG_IN_DOUBLE_P(n) ((n) < (1UL << DBL_MANT_DIG))
5378 # define RB_ULONG_IN_DOUBLE_P(n) 1
5380 #define RB_ULONG_TO_DOUBLE(n) (double)(n)
5381 #define RB_ULONG unsigned long
5384 #if 2*SIZEOF_BDIGIT > SIZEOF_LONG
5385 # if 2*SIZEOF_BDIGIT*CHAR_BIT > DBL_MANT_DIG
5386 # define BDIGIT_DBL_IN_DOUBLE_P(n) ((n) < ((BDIGIT_DBL)1UL << DBL_MANT_DIG))
5388 # define BDIGIT_DBL_IN_DOUBLE_P(n) 1
5390 # ifdef ULL_TO_DOUBLE
5391 # define BDIGIT_DBL_TO_DOUBLE(n) ULL_TO_DOUBLE(n)
5393 # define BDIGIT_DBL_TO_DOUBLE(n) (double)(n)
5398 #define domain_error(msg) \
5399 rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
5432 unsigned long n, sq;
5448 if (biglen == 0)
return INT2FIX(0);
5449 #if SIZEOF_BDIGIT <= SIZEOF_LONG
5560 #define rb_intern(str) rb_intern_const(str)
5678 #ifndef RUBY_INTEGER_UNIFICATION
5832 #undef rb_float_value
5836 return rb_float_value_inline(
v);
5843 return rb_float_new_inline(d);
VALUE rb_big_remainder(VALUE x, VALUE y)
VALUE rb_float_div(VALUE x, VALUE y)
VALUE rb_dbl_complex_new_polar_pi(double abs, double ang)
VALUE rb_int_divmod(VALUE x, VALUE y)
VALUE rb_fix2str(VALUE x, int base)
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
VALUE rb_big_eql(VALUE x, VALUE y)
VALUE rb_int_floor(VALUE num, int ndigits)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
const char * rb_id2name(ID)
char * ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
VALUE rb_int_ge(VALUE x, VALUE y)
VALUE rb_big_modulo(VALUE x, VALUE y)
unsigned short rb_fix2ushort(VALUE val)
void rb_include_module(VALUE klass, VALUE module)
VALUE rb_num_coerce_bin(VALUE x, VALUE y, ID func)
VALUE rb_assoc_new(VALUE car, VALUE cdr)
int rb_num_negative_p(VALUE num)
VALUE rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv, rb_enumerator_size_func *size_fn, VALUE beg, VALUE end, VALUE step, int excl)
VALUE rb_complex_pow(VALUE self, VALUE other)
double rb_big_fdiv_double(VALUE x, VALUE y)
VALUE rb_float_plus(VALUE x, VALUE y)
#define rb_enc_mbcput(c, buf, enc)
int rb_block_given_p(void)
Determines if the current method is given a block.
VALUE rb_float_abs(VALUE flt)
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE)
short rb_num2short(VALUE val)
double rb_int_fdiv_double(VALUE x, VALUE y)
VALUE rb_big_le(VALUE x, VALUE y)
VALUE rb_num_coerce_bit(VALUE x, VALUE y, ID func)
VALUE rb_big_ge(VALUE x, VALUE y)
char * strchr(char *, char)
VALUE rb_dbl_cmp(double a, double b)
VALUE rb_dbl2big(double d)
const union bytesequence4_or_float rb_infinity
VALUE rb_big_lshift(VALUE x, VALUE y)
VALUE rb_int2big(intptr_t n)
VALUE rb_equal(VALUE, VALUE)
Same as Object#===, case equality.
unsigned long rb_big2ulong(VALUE x)
#define RB_TYPE_P(obj, type)
#define rb_intern_const(str)
unsigned long rb_num2ulong(VALUE val)
#define FIXNUM_ZERO_P(num)
double rb_float_value(VALUE v)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
@ RUBY_NUM_ROUND_HALF_EVEN
VALUE rb_int_plus(VALUE x, VALUE y)
@ RUBY_NUM_ROUND_HALF_DOWN
VALUE rb_int_idiv(VALUE x, VALUE y)
#define LONG_MAX_PLUS_ONE
unsigned short rb_num2ushort(VALUE val)
#define DEFINE_INT_SQRT(rettype, prefix, argtype)
VALUE rb_inspect(VALUE)
Convenient wrapper of Object::inspect.
double ruby_float_step_size(double beg, double end, double unit, int excl)
VALUE rb_float_pow(VALUE x, VALUE y)
VALUE rb_big_or(VALUE x, VALUE y)
VALUE rb_int_truncate(VALUE num, int ndigits)
VALUE rb_check_string_type(VALUE)
VALUE rb_Float(VALUE)
Equivalent to Kernel#Float in Ruby.
long rb_big2long(VALUE x)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
VALUE rb_complex_mul(VALUE self, VALUE other)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
unsigned long rb_ulong_isqrt(unsigned long)
MJIT_FUNC_EXPORTED VALUE rb_flo_div_flo(VALUE x, VALUE y)
VALUE rb_int_equal(VALUE x, VALUE y)
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
void rb_name_error(ID id, const char *fmt,...)
VALUE rb_int_fdiv(VALUE x, VALUE y)
VALUE rb_rational_reciprocal(VALUE x)
#define SPECIAL_CONST_P(x)
#define MUL_OVERFLOW_FIXNUM_P(a, b)
#define rb_cmpint(cmp, a, b)
const union bytesequence4_or_float rb_nan
VALUE rb_big_gt(VALUE x, VALUE y)
size_t strlen(const char *)
VALUE rb_big_xor(VALUE x, VALUE y)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_int_gt(VALUE x, VALUE y)
VALUE rb_integer_float_cmp(VALUE x, VALUE y)
VALUE rb_int_lshift(VALUE x, VALUE y)
#define RARRAY_LENINT(ary)
VALUE rb_str_resize(VALUE, long)
VALUE rb_int_uminus(VALUE num)
int rb_bigzero_p(VALUE x)
MJIT_FUNC_EXPORTED int rb_float_cmp(VALUE x, VALUE y)
VALUE rb_big_uminus(VALUE x)
void rb_raise(VALUE exc, const char *fmt,...)
#define FLOAT_OUT_OF_RANGE(val, type)
VALUE rb_fix_plus(VALUE x, VALUE y)
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
#define BIGNUM_POSITIVE_P(b)
VALUE rb_int_mul(VALUE x, VALUE y)
VALUE rb_big_odd_p(VALUE num)
short rb_fix2short(VALUE val)
VALUE rb_big_isqrt(VALUE)
VALUE rb_int_cmp(VALUE x, VALUE y)
VALUE rb_big_and(VALUE x, VALUE y)
rb_encoding * rb_ascii8bit_encoding(void)
VALUE rb_num_coerce_relop(VALUE x, VALUE y, ID func)
VALUE rb_num2fix(VALUE val)
const typedef OnigEncodingType rb_encoding
VALUE rb_float_ceil(VALUE num, int ndigits)
VALUE rb_int_modulo(VALUE x, VALUE y)
VALUE rb_big_cmp(VALUE x, VALUE y)
ID rb_frame_this_func(void)
The original name of the current method.
VALUE rb_yield_1(VALUE val)
VALUE rb_eFloatDomainError
#define domain_error(msg)
VALUE rb_big_divmod(VALUE x, VALUE y)
long rb_num2long(VALUE val)
long rb_fix2int(VALUE val)
int rb_memcicmp(const void *, const void *, long)
VALUE rb_ary_push(VALUE ary, VALUE item)
VALUE rb_int_abs(VALUE num)
VALUE rb_complex_new(VALUE x, VALUE y)
VALUE rb_float_mul(VALUE x, VALUE y)
COMPILER_WARNING_POP VALUE rb_integer_float_eq(VALUE x, VALUE y)
RUBY_EXTERN double nan(const char *)
VALUE rb_int_minus(VALUE x, VALUE y)
VALUE rb_big_idiv(VALUE x, VALUE y)
VALUE rb_int_powm(int const argc, VALUE *const argv, VALUE const num)
#define RARRAY_AREF(a, i)
VALUE rb_int_positive_pow(long x, unsigned long y)
long rb_num2int(VALUE val)
VALUE rb_int_ceil(VALUE num, int ndigits)
VALUE rb_big_minus(VALUE x, VALUE y)
VALUE rb_num_coerce_cmp(VALUE x, VALUE y, ID func)
VALUE rb_to_int(VALUE)
Converts val into Integer.
#define RGENGC_WB_PROTECTED_FLOAT
int rb_int_positive_p(VALUE num)
MJIT_STATIC void rb_error_arity(int argc, int min, int max)
rb_encoding * rb_default_internal_encoding(void)
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts)
RUBY_EXTERN VALUE rb_eMathDomainError
#define SIZED_ENUMERATOR(obj, argc, argv, size_fn)
VALUE rb_int_pow(VALUE x, VALUE y)
#define RARRAY_CONST_PTR(a)
VALUE rb_float_gt(VALUE x, VALUE y)
void rb_num_zerodiv(void)
VALUE rb_big_rshift(VALUE x, VALUE y)
VALUE rb_big_eq(VALUE x, VALUE y)
VALUE rb_flo_is_infinite_p(VALUE num)
#define FIXNUM_POSITIVE_P(num)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_int_and(VALUE x, VALUE y)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_rational_pow(VALUE self, VALUE other)
VALUE rb_int_div(VALUE x, VALUE y)
void rb_bug(const char *fmt,...)
VALUE rb_big_even_p(VALUE num)
rb_encoding * rb_to_encoding(VALUE enc)
MJIT_FUNC_EXPORTED double ruby_float_mod(double x, double y)
#define ONIGERR_INVALID_CODE_POINT_VALUE
VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
#define LONG_MIN_MINUS_ONE_IS_LESS_THAN(n)
VALUE rb_flo_is_finite_p(VALUE num)
#define BIGNUM_NEGATIVE_P(b)
void rb_cmperr(VALUE x, VALUE y)
char str[HTML_ESCAPE_MAX_LEN+1]
VALUE rb_big_size_m(VALUE big)
VALUE rb_rational_raw(VALUE, VALUE)
#define ULONG_MAX_PLUS_ONE
VALUE rb_float_uminus(VALUE flt)
VALUE rb_big_mul(VALUE x, VALUE y)
MJIT_FUNC_EXPORTED VALUE rb_float_equal(VALUE x, VALUE y)
int rb_num_to_uint(VALUE val, unsigned int *ret)
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
const char * rb_obj_classname(VALUE)
#define ROUND_CALL(mode, name, args)
VALUE rb_big_plus(VALUE x, VALUE y)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
VALUE rb_big2str(VALUE x, int base)
void rb_define_const(VALUE, const char *, VALUE)
const char ruby_digitmap[]
VALUE rb_big_norm(VALUE x)
int rb_int_negative_p(VALUE num)
#define FIXNUM_NEGATIVE_P(num)
void rb_deprecate_constant(VALUE mod, const char *name)
#define MJIT_FUNC_EXPORTED
NORETURN(static void num_funcall_op_1_recursion(VALUE x, ID func, VALUE y))
int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
VALUE rb_big_bit_length(VALUE big)
VALUE rb_str_catf(VALUE str, const char *format,...)
VALUE rb_big_div(VALUE x, VALUE y)
VALUE rb_big_pow(VALUE x, VALUE y)
#define rb_usascii_str_new2
VALUE rb_big_aref(VALUE x, VALUE y)
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
VALUE rb_exec_recursive_paired(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE, VALUE)
MJIT_FUNC_EXPORTED VALUE rb_float_eql(VALUE x, VALUE y)
VALUE rb_complex_plus(VALUE self, VALUE other)
int rb_enc_codelen(int c, rb_encoding *enc)
VALUE rb_num_pow(VALUE x, VALUE y)
VALUE rb_big_lt(VALUE x, VALUE y)
int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless)
VALUE rb_int_succ(VALUE num)
#define RB_INTEGER_TYPE_P(obj)
VALUE rb_big_abs(VALUE x)
#define NEWOBJ_OF(obj, type, klass, flags)
double rb_big2dbl(VALUE x)
size_t rb_big_size(VALUE big)
void rb_remove_method_id(VALUE, ID)
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
VALUE rb_float_new_in_heap(double d)
void rb_undef_alloc_func(VALUE)
VALUE rb_float_new(double d)
#define UNREACHABLE_RETURN(val)
RUBY_EXTERN double nextafter(double x, double y)
VALUE rb_gcd(VALUE x, VALUE y)
VALUE rb_any_to_s(VALUE)
Default implementation of #to_s.
VALUE rb_big_comp(VALUE x)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
VALUE rb_str_cat(VALUE, const char *, long)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Determines if obj is a kind of c.
long rb_dbl_long_hash(double d)
MJIT_FUNC_EXPORTED VALUE rb_fix_aref(VALUE fix, VALUE idx)
VALUE rb_int_odd_p(VALUE num)
#define method_basic_p(klass)
#define RBIGNUM_NEGATIVE_P(b)
#define RB_FLOAT_TYPE_P(obj)
VALUE rb_int2str(VALUE x, int base)