36 #define DBL_MIN 2.2250738585072014e-308 39 #define DBL_MAX 1.7976931348623157e+308 42 #define DBL_MIN_EXP (-1021) 45 #define DBL_MAX_EXP 1024 47 #ifndef DBL_MIN_10_EXP 48 #define DBL_MIN_10_EXP (-307) 50 #ifndef DBL_MAX_10_EXP 51 #define DBL_MAX_10_EXP 308 57 #define DBL_MANT_DIG 53 60 #define DBL_EPSILON 2.2204460492503131e-16 64 #elif !defined(WORDS_BIGENDIAN) 71 #elif !defined(WORDS_BIGENDIAN) 85 x = f + (x - f >= 0.5);
89 x = f - (f - x >= 0.5);
96 round_half_up(
double x,
double s)
101 if (s == 1.0)
return f;
103 if ((
double)((f + 0.5) / s) <= x) f += 1;
107 if ((
double)((f - 0.5) / s) >= x) f -= 1;
114 round_half_down(
double x,
double s)
116 double f, xs = x * s;
120 if ((
double)((f - 0.5) / s) >= x) f -= 1;
124 if ((
double)((f + 0.5) / s) <= x) f += 1;
131 round_half_even(
double x,
double s)
133 double f, d, xs = x * s;
140 else if (d == 0.5 || ((
double)((f + 0.5) / s) <= x))
151 else if (d == 0.5 || ((
double)((f - 0.5) / s) >= x))
162 static VALUE fix_lshift(
long,
unsigned long);
163 static VALUE fix_rshift(
long,
unsigned long);
164 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);
174 static ID id_coerce, id_div, id_divmod;
175 #define id_to_i idTo_i 182 #ifndef RUBY_INTEGER_UNIFICATION 189 static ID id_to, id_by;
200 static ID round_kwds[1];
206 if (!round_kwds[0]) {
209 if (!
rb_get_kwargs(opts, round_kwds, 0, 1, &rounding))
goto noopt;
213 else if (
NIL_P(rounding)) {
218 if (
NIL_P(str))
goto invalid;
244 #define NUMERR_TYPE 1 245 #define NUMERR_NEGATIVE 2 246 #define NUMERR_TOOLARGE 3 249 #if SIZEOF_INT < SIZEOF_LONG 253 *ret = (
unsigned int)v;
259 #if SIZEOF_INT < SIZEOF_LONG 272 #define method_basic_p(klass) rb_method_basic_definition_p(klass, mid) 275 compare_with_zero(
VALUE num,
ID mid)
310 positive_int_p(
VALUE num)
322 return RTEST(compare_with_zero(num, mid));
326 negative_int_p(
VALUE num)
338 return RTEST(compare_with_zero(num, mid));
344 return negative_int_p(num);
348 num_funcall_op_0(
VALUE x,
VALUE arg,
int recursive)
357 else if (name[0] && name[1] ==
'@' && !name[2]) {
390 num_funcall_op_1(
VALUE y,
VALUE arg,
int recursive)
395 num_funcall_op_1_recursion(x, func, y);
404 args[0] = (
VALUE)func;
456 coerce_failed(*x, *y);
460 if (!err &&
NIL_P(ary)) {
475 do_coerce(&x, &y,
TRUE);
482 if (do_coerce(&x, &y,
FALSE))
490 VALUE c, x0 = x, y0 = y;
492 if (!do_coerce(&x, &y,
FALSE) ||
535 # define num_clone rb_immutable_obj_clone 551 # define num_dup num_uplus 579 num_imaginary(
VALUE num)
592 num_uminus(
VALUE num)
597 do_coerce(&zero, &num,
TRUE);
599 return num_funcall1(zero,
'-', num);
648 VALUE q = num_funcall1(x, id_div, y);
665 VALUE z = num_funcall1(x,
'%', y);
668 ((negative_int_p(x) &&
669 positive_int_p(y)) ||
670 (positive_int_p(x) &&
671 negative_int_p(y)))) {
734 num_real_p(
VALUE num)
772 if (negative_int_p(num)) {
786 num_zero_p(
VALUE num)
819 num_nonzero_p(
VALUE num)
834 num_finite_p(
VALUE num)
847 num_infinite_p(
VALUE num)
864 num_to_int(
VALUE num)
866 return num_funcall0(num,
id_to_i);
877 num_positive_p(
VALUE num)
889 return compare_with_zero(num, mid);
900 num_negative_p(
VALUE num)
926 flt->float_value = d;
944 enum {float_dig = DBL_DIG+1};
949 int sign, decpt, digs;
952 static const char minf[] =
"-Infinity";
953 const int pos = (value > 0);
956 else if (
isnan(value))
959 p =
ruby_dtoa(value, 0, 0, &decpt, &sign, &e);
961 if ((digs = (
int)(e - p)) >= (
int)
sizeof(
buf)) digs = (int)
sizeof(
buf) - 1;
962 memcpy(
buf, p, digs);
970 else if (decpt <= DBL_DIG) {
977 memset(ptr,
'0', decpt - digs);
980 memcpy(ptr,
".0", 2);
986 else if (decpt > -4) {
992 memset(ptr += len,
'0', -decpt);
993 memcpy(ptr -= decpt,
buf, digs);
1155 return num_funcall1(x,
'/', y);
1159 flodivmod(
double x,
double y,
double *divp,
double *modp)
1165 if (modp) *modp = y;
1166 if (divp) *divp = y;
1185 div = (x -
mod) / y;
1186 if (modp && divp) div =
round(div);
1192 if (modp) *modp =
mod;
1193 if (divp) *divp =
div;
1205 flodivmod(x, y, 0, &mod);
1263 volatile VALUE a, b;
1307 if (dx < 0 && dy !=
round(dy))
1350 if (x == y)
return INT2FIX(0);
1358 if (x == y)
return Qtrue;
1359 result = num_funcall1(y,
id_eq, x);
1380 volatile double a, b;
1387 #if defined(_MSC_VER) && _MSC_VER < 1300 1392 return num_equal(x, y);
1395 #if defined(_MSC_VER) && _MSC_VER < 1300 1401 #define flo_eq rb_float_equal 1428 if (a == b)
return INT2FIX(0);
1430 if (a < b)
return INT2FIX(-1);
1469 j = (a > 0.0) ? (j > 0 ? 0 : +1) : (j < 0 ? 0 : -1);
1472 if (a > 0.0)
return INT2FIX(1);
1483 return NUM2INT(flo_cmp(x, y));
1510 #if defined(_MSC_VER) && _MSC_VER < 1300 1517 #if defined(_MSC_VER) && _MSC_VER < 1300 1547 #if defined(_MSC_VER) && _MSC_VER < 1300 1554 #if defined(_MSC_VER) && _MSC_VER < 1300 1584 #if defined(_MSC_VER) && _MSC_VER < 1300 1591 #if defined(_MSC_VER) && _MSC_VER < 1300 1621 #if defined(_MSC_VER) && _MSC_VER < 1300 1628 #if defined(_MSC_VER) && _MSC_VER < 1300 1653 #if defined(_MSC_VER) && _MSC_VER < 1300 1662 #define flo_eql rb_float_eql 1706 flo_zero_p(
VALUE num)
1727 flo_is_nan_p(
VALUE num)
1752 return INT2FIX( value < 0 ? -1 : 1 );
1771 #ifdef HAVE_ISFINITE 1835 flo_next_float(
VALUE vx)
1886 flo_prev_float(
VALUE vx)
1943 if (number == 0.0) {
1948 frexp(number, &binexp);
1949 if (float_round_overflow(ndigits, binexp))
return num;
1950 if (number > 0.0 && float_round_underflow(ndigits, binexp))
1952 f = pow(10, ndigits);
1953 f = floor(number * f) /
f;
1957 num = dbl2ival(floor(number));
2012 if (number == 0.0) {
2017 frexp(number, &binexp);
2018 if (float_round_overflow(ndigits, binexp))
return num;
2019 if (number < 0.0 && float_round_underflow(ndigits, binexp))
2021 f = pow(10, ndigits);
2022 f = ceil(number * f) /
f;
2026 num = dbl2ival(ceil(number));
2033 int_round_zero_p(
VALUE num,
int ndigits)
2039 bytes =
sizeof(long);
2047 return (-0.415241 * ndigits - 0.125 > bytes);
2054 if ((z * y - x) * 2 == y) {
2063 return (x + y / 2) / y * y;
2069 return (x + y / 2 - 1) / y * y;
2081 return int_pos_p(num);
2087 return int_neg_p(num);
2098 if (int_round_zero_p(num, ndigits)) {
2102 f = int_pow(10, -ndigits);
2131 if (int_round_zero_p(num, ndigits))
2133 f = int_pow(10, -ndigits);
2137 if (neg) x = -x + y - 1;
2154 if (int_round_zero_p(num, ndigits))
2156 f = int_pow(10, -ndigits);
2179 if (int_round_zero_p(num, ndigits))
2181 f = int_pow(10, -ndigits);
2195 if (int_neg_p(num)) {
2258 double number,
f, x;
2268 if (number == 0.0) {
2280 frexp(number, &binexp);
2281 if (float_round_overflow(ndigits, binexp))
return num;
2282 if (float_round_underflow(ndigits, binexp))
return DBL2NUM(0);
2283 f = pow(10, ndigits);
2291 float_round_overflow(
int ndigits,
int binexp)
2312 if (ndigits >= float_dig - (binexp > 0 ? binexp / 4 : binexp / 3 - 1)) {
2319 float_round_underflow(
int ndigits,
int binexp)
2321 if (ndigits < - (binexp > 0 ? binexp / 3 + 1 : binexp / 4)) {
2350 if (f > 0.0) f = floor(f);
2351 if (f < 0.0) f = ceil(f);
2396 flo_positive_p(
VALUE num)
2410 flo_negative_p(
VALUE num)
2485 ruby_float_step_size(
double beg,
double end,
double unit,
int excl)
2488 double n = (end - beg)/unit;
2489 double err = (fabs(beg) + fabs(end) + fabs(end-beg)) / fabs(unit) * epsilon;
2492 return unit > 0 ? beg <= end : beg >= end;
2497 if (err>0.5) err=0.5;
2519 double n = ruby_float_step_size(beg, end, unit, excl);
2526 else if (unit == 0) {
2532 for (i=0; i<n; i++) {
2533 double d = i*unit+beg;
2534 if (unit >= 0 ? end < d : d < end) d = end;
2578 case -1: cmp =
'<';
break;
2590 num_step_negative_p(
VALUE num)
2607 coerce_failed(num,
INT2FIX(0));
2625 if (values[0] !=
Qundef) {
2629 if (values[1] !=
Qundef) {
2646 desc = num_step_negative_p(*step);
2660 num_step_scan_args(argc, argv, &to, &step);
2725 desc = num_step_scan_args(
argc,
argv, &to, &step);
2747 for (; i >= end; i += diff)
2751 for (; i <= end; i += diff)
2764 ID cmp = desc ?
'<' :
'>';
2774 out_of_range_float(
char (*pbuf)[24],
VALUE val)
2776 char *
const buf = *pbuf;
2780 if ((s =
strchr(buf,
' ')) != 0) *s =
'\0';
2784 #define FLOAT_OUT_OF_RANGE(val, type) do { \ 2786 rb_raise(rb_eRangeError, "float %s out of range of "type, \ 2787 out_of_range_float(&buf, (val))); \ 2790 #define LONG_MIN_MINUS_ONE ((double)LONG_MIN-1) 2791 #define LONG_MAX_PLUS_ONE (2*(double)(LONG_MAX/2+1)) 2792 #define ULONG_MAX_PLUS_ONE (2*(double)(ULONG_MAX/2+1)) 2793 #define LONG_MIN_MINUS_ONE_IS_LESS_THAN(n) \ 2794 (LONG_MIN_MINUS_ONE == (double)LONG_MIN ? \ 2796 LONG_MIN_MINUS_ONE < (n)) 2826 static unsigned long 2827 rb_num2ulong_internal(
VALUE val,
int *wrap_p)
2838 return (
unsigned long)l;
2844 *wrap_p = d <= -1.0;
2846 return (
unsigned long)d;
2847 return (
unsigned long)(long)d;
2870 return rb_num2ulong_internal(val,
NULL);
2873 #if SIZEOF_INT < SIZEOF_LONG 2878 num, num < 0 ?
"small" :
"big");
2884 if ((
long)(
int)num != num) {
2890 check_uint(
unsigned long num,
int sign)
2894 if (num < (
unsigned long)INT_MIN)
2926 unsigned long num = rb_num2ulong_internal(val, &wrap);
2928 check_uint(num, wrap);
2938 return rb_num2uint(val);
2942 check_uint(num, negative_int_p(val));
2964 num, num < 0 ?
"small" :
"big");
2968 check_short(
long num)
2970 if ((
long)(
short)num != num) {
2971 rb_out_of_short(num);
2976 check_ushort(
unsigned long num,
int sign)
2980 if (num < (
unsigned long)SHRT_MIN)
2985 if (USHRT_MAX < num)
3012 unsigned long num = rb_num2ulong_internal(val, &wrap);
3014 check_ushort(num, wrap);
3028 check_ushort(num, negative_int_p(val));
3047 #define LLONG_MIN_MINUS_ONE ((double)LLONG_MIN-1) 3048 #define LLONG_MAX_PLUS_ONE (2*(double)(LLONG_MAX/2+1)) 3049 #define ULLONG_MAX_PLUS_ONE (2*(double)(ULLONG_MAX/2+1)) 3051 #define ULLONG_MAX ((unsigned LONG_LONG)LLONG_MAX*2+1) 3053 #define LLONG_MIN_MINUS_ONE_IS_LESS_THAN(n) \ 3054 (LLONG_MIN_MINUS_ONE == (double)LLONG_MIN ? \ 3056 LLONG_MIN_MINUS_ONE < (n)) 3069 if (d < LLONG_MAX_PLUS_ONE && (LLONG_MIN_MINUS_ONE_IS_LESS_THAN(d))) {
3070 return (LONG_LONG)d;
3077 return rb_big2ll(val);
3101 if (d < ULLONG_MAX_PLUS_ONE && LLONG_MIN_MINUS_ONE_IS_LESS_THAN(d)) {
3103 return (
unsigned LONG_LONG)d;
3104 return (
unsigned LONG_LONG)(LONG_LONG)d;
3111 return rb_big2ull(val);
3121 return NUM2ULL(val);
3159 int_int_p(
VALUE num)
3172 int_odd_p(
VALUE num)
3196 int_even_p(
VALUE num)
3199 if ((num & 2) == 0) {
3238 return num_funcall1(num,
'+',
INT2FIX(1));
3241 #define int_succ rb_int_succ 3264 return num_funcall1(num,
'-',
INT2FIX(1));
3267 #define int_pred rb_int_pred 3382 fix_uminus(
VALUE num)
3391 return fix_uminus(num);
3396 return num_funcall0(num,
idUMinus);
3424 if (base < 2 || 36 < base) {
3427 #if SIZEOF_LONG < SIZEOF_VOIDP 3428 # if SIZEOF_VOIDP == SIZEOF_LONG_LONG 3429 if ((val >= 0 && (x & 0xFFFFFFFF00000000ull)) ||
3430 (val < 0 && (x & 0xFFFFFFFF00000000ull) != 0xFFFFFFFF00000000ull)) {
3431 rb_bug(
"Unnormalized Fixnum value %p", (
void *)x);
3442 u = 1 + (
unsigned long)(-(val + 1));
3450 }
while (u /= base);
3496 return rb_fix_plus_fix(x, y);
3515 return fix_plus(x, y);
3522 return fix_plus(x, y);
3543 return rb_fix_minus_fix(x, y);
3561 return fix_minus(x, y);
3570 #define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2)) 3572 #define FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX)) 3587 return rb_fix_mul_fix(x, y);
3611 return fix_mul(x, y);
3647 return fix_fdiv_double(x, y);
3690 return rb_fix_div_fix(x, y);
3722 return fix_divide(x, y,
'/');
3729 return fix_div(x, y);
3749 return fix_divide(x, y, id_div);
3756 return fix_idiv(x, y);
3761 return num_div(x, y);
3781 return rb_fix_mod_fix(x, y);
3799 return fix_mod(x, y);
3804 return num_modulo(x, y);
3828 return num_remainder(x, y);
3849 rb_fix_divmod_fix(x, y, &div, &mod);
3859 volatile VALUE a, b;
3876 return fix_divmod(x, y);
3904 int_pow(
long x,
unsigned long y)
3909 if (y == 0)
return INT2FIX(1);
3917 while (y % 2 == 0) {
3944 return int_pow(x, y);
3955 if (a == 1)
return INT2FIX(1);
3965 if (b == 0)
return INT2FIX(1);
3966 if (b == 1)
return x;
3971 return int_pow(a, b);
3974 if (a == 1)
return INT2FIX(1);
3976 if (int_even_p(y))
return INT2FIX(1);
3979 if (negative_int_p(y))
3981 if (a == 0)
return INT2FIX(0);
3987 if (dy == 0.0)
return DBL2NUM(1.0);
3991 if (a == 1)
return DBL2NUM(1.0);
3993 if (a < 0 && dy !=
round(dy))
3995 return DBL2NUM(pow((
double)a, dy));
4007 return fix_pow(x, y);
4031 if (x == y)
return Qtrue;
4040 return num_equal(x, y);
4048 return fix_equal(x, y);
4072 if (x == y)
return INT2FIX(0);
4098 return fix_cmp(x, y);
4138 return fix_gt(x, y);
4178 return fix_ge(x, y);
4216 return fix_lt(x, y);
4256 return fix_le(x, y);
4289 return fix_comp(num);
4298 num_funcall_bit_1(
VALUE y,
VALUE arg,
int recursive)
4303 num_funcall_op_1_recursion(x, func, y);
4313 args[0] = (
VALUE)func;
4316 do_coerce(&args[1], &args[2],
TRUE);
4318 args[2], args[1], (
VALUE)args);
4321 coerce_failed(x, y);
4353 return fix_and(x, y);
4388 return fix_or(x, y);
4423 return fix_xor(x, y);
4450 return fix_rshift(val, (
unsigned long)-width);
4451 return fix_lshift(val, width);
4455 fix_lshift(
long val,
unsigned long width)
4457 if (width > (SIZEOF_LONG*
CHAR_BIT-1)
4458 || ((
unsigned long)
val)>>(SIZEOF_LONG*
CHAR_BIT-1-width) > 0) {
4469 return rb_fix_lshift(x, y);
4495 if (i == 0)
return x;
4497 return fix_lshift(val, (
unsigned long)-i);
4498 return fix_rshift(val, i);
4502 fix_rshift(
long val,
unsigned long i)
4504 if (i >=
sizeof(
long)*
CHAR_BIT-1) {
4516 return rb_fix_rshift(x, y);
4561 if (val < 0)
return INT2FIX(1);
4573 return fix_aref(num, idx);
4638 return fix_abs(num);
4672 return fix_size(num);
4726 rb_fix_bit_length(
VALUE fix)
4735 rb_int_bit_length(
VALUE num)
4738 return rb_fix_bit_length(num);
4767 rb_fix_digits(
VALUE fix,
long base)
4806 return rb_fix_digits(num,
FIX2LONG(base));
4836 return rb_int_digits_bigbase(num, base_value);
4848 return rb_fix_digits(num, base);
4850 return rb_int_digits_bigbase(num,
LONG2FIX(base));
4883 for (i =
FIX2LONG(from); i <= end; i++) {
4929 for (i=
FIX2LONG(from); i >= end; i--) {
4972 int_dotimes(
VALUE num)
4980 for (i=0; i<end; i++) {
5140 #define DEFINE_INT_SQRT(rettype, prefix, argtype) \ 5142 prefix##_isqrt(argtype n) \ 5144 if (!argtype##_IN_DOUBLE_P(n)) { \ 5145 unsigned int b = bit_length(n); \ 5147 rettype x = (rettype)(n >> (b/2+1)); \ 5148 x |= ((rettype)1LU << (b-1)/2); \ 5149 while ((t = n/x) < (argtype)x) x = (rettype)((x + t) >> 1); \ 5152 return (rettype)sqrt(argtype##_TO_DOUBLE(n)); \ 5155 #if SIZEOF_LONG*CHAR_BIT > DBL_MANT_DIG 5156 # define RB_ULONG_IN_DOUBLE_P(n) ((n) < (1UL << DBL_MANT_DIG)) 5158 # define RB_ULONG_IN_DOUBLE_P(n) 1 5160 #define RB_ULONG_TO_DOUBLE(n) (double)(n) 5161 #define RB_ULONG unsigned long 5164 #if 2*SIZEOF_BDIGIT > SIZEOF_LONG 5165 # if 2*SIZEOF_BDIGIT*CHAR_BIT > DBL_MANT_DIG 5166 # define BDIGIT_DBL_IN_DOUBLE_P(n) ((n) < ((BDIGIT_DBL)1UL << DBL_MANT_DIG)) 5168 # define BDIGIT_DBL_IN_DOUBLE_P(n) 1 5170 # ifdef ULL_TO_DOUBLE 5171 # define BDIGIT_DBL_TO_DOUBLE(n) ULL_TO_DOUBLE(n) 5173 # define BDIGIT_DBL_TO_DOUBLE(n) (double)(n) 5178 #define domain_error(msg) \ 5179 rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg) 5212 unsigned long n, sq;
5228 if (biglen == 0)
return INT2FIX(0);
5229 #if SIZEOF_BDIGIT <= SIZEOF_LONG 5339 #define rb_intern(str) rb_intern_const(str) 5452 #ifndef RUBY_INTEGER_UNIFICATION 5605 #undef rb_float_value 5609 return rb_float_value_inline(v);
5616 return rb_float_new_inline(d);
unsigned short rb_fix2ushort(VALUE val)
VALUE rb_big_modulo(VALUE x, VALUE y)
int rb_bigzero_p(VALUE x)
#define FIXNUM_POSITIVE_P(num)
int rb_enc_codelen(int c, rb_encoding *enc)
short rb_num2short(VALUE val)
void rb_bug(const char *fmt,...)
int rb_float_cmp(VALUE x, VALUE y)
VALUE rb_int_floor(VALUE num, int ndigits)
size_t strlen(const char *)
VALUE rb_int_ge(VALUE x, VALUE y)
double rb_int_fdiv_double(VALUE x, VALUE y)
VALUE rb_num_coerce_bit(VALUE x, VALUE y, ID func)
void rb_undef_alloc_func(VALUE)
RUBY_EXTERN int signbit(double x)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
VALUE rb_int_truncate(VALUE num, int ndigits)
#define rb_usascii_str_new2
void rb_raise(VALUE exc, const char *fmt,...)
const union bytesequence4_or_float rb_infinity
VALUE rb_str_cat(VALUE, const char *, long)
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
VALUE rb_int_plus(VALUE x, VALUE y)
#define LONG_MAX_PLUS_ONE
double rb_float_value(VALUE v)
const char ruby_digitmap[]
unsigned long rb_big2ulong(VALUE x)
#define ONIGERR_INVALID_CODE_POINT_VALUE
VALUE rb_big_odd_p(VALUE num)
VALUE rb_big_eql(VALUE x, VALUE y)
VALUE rb_big_plus(VALUE x, VALUE y)
unsigned long rb_num2ulong(VALUE val)
rb_encoding * rb_to_encoding(VALUE enc)
double ruby_float_mod(double x, double y)
size_t rb_big_size(VALUE big)
VALUE rb_fix2str(VALUE x, int base)
VALUE rb_dbl_cmp(double a, double b)
VALUE rb_float_abs(VALUE flt)
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
RUBY_EXTERN VALUE rb_eMathDomainError
VALUE rb_big_bit_length(VALUE big)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_integer_float_cmp(VALUE x, VALUE y)
long rb_dbl_long_hash(double d)
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
int rb_num_negative_p(VALUE num)
VALUE rb_big_isqrt(VALUE)
VALUE rb_int_equal(VALUE x, VALUE y)
void rb_include_module(VALUE klass, VALUE module)
double rb_big2dbl(VALUE x)
VALUE rb_num2fix(VALUE val)
#define rb_complex_raw1(x)
VALUE rb_float_pow(VALUE x, VALUE y)
unsigned short rb_num2ushort(VALUE val)
VALUE rb_int_gt(VALUE x, VALUE y)
VALUE rb_int_lshift(VALUE x, VALUE y)
VALUE rb_int_pred(VALUE num)
VALUE rb_inspect(VALUE)
Convenient wrapper of Object::inspect.
void rb_name_error(ID id, const char *fmt,...)
#define DEFINE_INT_SQRT(rettype, prefix, argtype)
void rb_undef_method(VALUE klass, const char *name)
#define FLOAT_OUT_OF_RANGE(val, type)
const char * rb_obj_classname(VALUE)
RUBY_EXTERN void * memmove(void *, const void *, size_t)
VALUE rb_int_modulo(VALUE x, VALUE y)
short rb_fix2short(VALUE val)
#define NEWOBJ_OF(obj, type, klass, flags)
const union bytesequence4_or_float rb_nan
VALUE rb_fix_plus(VALUE x, VALUE y)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
VALUE rb_obj_class(VALUE)
call-seq: obj.class -> class
#define RB_TYPE_P(obj, type)
VALUE rb_big_divmod(VALUE x, VALUE y)
VALUE rb_int_cmp(VALUE x, VALUE y)
VALUE rb_int_idiv(VALUE x, VALUE y)
VALUE rb_big_ge(VALUE x, VALUE y)
unsigned long rb_ulong_isqrt(unsigned long)
VALUE rb_equal(VALUE, VALUE)
call-seq: obj === other -> true or false
#define rb_rational_raw1(x)
VALUE rb_dbl2big(double d)
VALUE rb_big_eq(VALUE x, VALUE y)
#define ROUND_CALL(mode, name, args)
VALUE rb_complex_mul(VALUE self, VALUE other)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_int_fdiv(VALUE x, VALUE y)
VALUE rb_exec_recursive_paired(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE, VALUE)
long rb_num2long(VALUE val)
VALUE rb_int_mul(VALUE x, VALUE y)
VALUE rb_int_positive_pow(long x, unsigned long y)
VALUE rb_big_cmp(VALUE x, VALUE y)
VALUE rb_any_to_s(VALUE)
call-seq: obj.to_s -> string
VALUE rb_num_coerce_relop(VALUE x, VALUE y, ID func)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
void rb_define_const(VALUE, const char *, VALUE)
void rb_remove_method_id(VALUE, ID)
int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl)
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE)
#define BIGNUM_NEGATIVE_P(b)
VALUE rb_flo_is_infinite_p(VALUE num)
RUBY_EXTERN int isinf(double)
VALUE rb_int_minus(VALUE x, VALUE y)
VALUE rb_int_uminus(VALUE num)
void rb_num_zerodiv(void)
VALUE rb_eFloatDomainError
char * ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
VALUE rb_big2str(VALUE x, int base)
#define domain_error(msg)
VALUE rb_str_resize(VALUE, long)
VALUE rb_flo_is_finite_p(VALUE num)
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)
VALUE rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode)
#define RARRAY_CONST_PTR(a)
void rb_deprecate_constant(VALUE mod, const char *name)
#define MUL_OVERFLOW_FIXNUM_P(a, b)
long rb_fix2int(VALUE val)
VALUE rb_big_div(VALUE x, VALUE y)
VALUE rb_big_idiv(VALUE x, VALUE y)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
VALUE rb_float_eql(VALUE x, VALUE y)
VALUE rb_big_size_m(VALUE big)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
long rb_big2long(VALUE x)
#define FIXNUM_NEGATIVE_P(num)
VALUE rb_num_coerce_cmp(VALUE x, VALUE y, ID func)
VALUE rb_int_and(VALUE x, VALUE y)
VALUE rb_big_mul(VALUE x, VALUE y)
#define LONG_MIN_MINUS_ONE_IS_LESS_THAN(n)
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
char * strchr(char *, char)
VALUE rb_int_pow(VALUE x, VALUE y)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
#define rb_cmpint(cmp, a, b)
const char * rb_id2name(ID)
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
VALUE rb_big_even_p(VALUE num)
VALUE rb_big_gt(VALUE x, VALUE y)
#define RARRAY_LENINT(ary)
VALUE rb_int_abs(VALUE num)
VALUE rb_complex_new(VALUE x, VALUE y)
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts)
#define RB_FLOAT_TYPE_P(obj)
VALUE rb_big_comp(VALUE x)
register unsigned int len
VALUE rb_int_ceil(VALUE num, int ndigits)
VALUE rb_big_uminus(VALUE x)
VALUE rb_int_div(VALUE x, VALUE y)
double rb_big_fdiv_double(VALUE x, VALUE y)
VALUE rb_big_remainder(VALUE x, VALUE y)
VALUE rb_dbl_hash(double d)
long rb_num2int(VALUE val)
#define RARRAY_AREF(a, i)
VALUE rb_Float(VALUE)
Equivalent to Kernel#Float in Ruby.
VALUE rb_big_and(VALUE x, VALUE y)
VALUE rb_rational_reciprocal(VALUE x)
#define FIXNUM_ZERO_P(num)
VALUE rb_str_catf(VALUE str, const char *format,...)
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE
VALUE rb_check_string_type(VALUE)
VALUE rb_big_norm(VALUE x)
VALUE rb_float_new(double d)
VALUE rb_big_lshift(VALUE x, VALUE y)
#define ULONG_MAX_PLUS_ONE
VALUE rb_float_new_in_heap(double d)
#define RGENGC_WB_PROTECTED_FLOAT
VALUE rb_float_uminus(VALUE flt)
VALUE rb_float_gt(VALUE x, VALUE y)
#define method_basic_p(klass)
VALUE rb_complex_plus(VALUE self, VALUE other)
VALUE rb_big_pow(VALUE x, VALUE y)
int rb_num_to_uint(VALUE val, unsigned int *ret)
#define BIGNUM_POSITIVE_P(b)
VALUE rb_int2big(SIGNED_VALUE n)
VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
VALUE rb_big_aref(VALUE x, VALUE y)
VALUE rb_integer_float_eq(VALUE x, VALUE y)
VALUE rb_gcd(VALUE x, VALUE y)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
NORETURN(static void coerce_failed(VALUE x, VALUE y))
VALUE rb_big_le(VALUE x, VALUE y)
VALUE rb_int_succ(VALUE num)
VALUE rb_yield_1(VALUE val)
RUBY_EXTERN double nextafter(double x, double y)
VALUE rb_int_divmod(VALUE x, VALUE y)
VALUE rb_float_equal(VALUE x, VALUE y)
VALUE rb_big_lt(VALUE x, VALUE y)
VALUE() rb_ary_new_from_args(long n,...)
rb_encoding * rb_ascii8bit_encoding(void)
#define rb_intern_const(str)
#define RBIGNUM_NEGATIVE_P(b)
VALUE rb_big_rshift(VALUE x, VALUE y)
#define SPECIAL_CONST_P(x)
VALUE rb_int2str(VALUE x, int base)
#define rb_enc_mbcput(c, buf, enc)
VALUE rb_usascii_str_new(const char *, long)
#define RB_INTEGER_TYPE_P(obj)
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
VALUE int_remainder(VALUE x, VALUE y)
VALUE rb_big_abs(VALUE x)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
int rb_memcicmp(const void *, const void *, long)
VALUE rb_big_or(VALUE x, VALUE y)
void rb_cmperr(VALUE x, VALUE y)
VALUE rb_to_int(VALUE)
Converts val into Integer.
VALUE rb_usascii_str_new_cstr(const char *)
VALUE rb_big_xor(VALUE x, VALUE y)
VALUE rb_num_coerce_bin(VALUE x, VALUE y, ID func)
VALUE rb_str_new(const char *, long)