Feature #12484 » 0001-export-functions.patch
internal.h | ||
---|---|---|
VALUE rb_dbl_hash(double d);
|
||
VALUE rb_fix_plus(VALUE x, VALUE y);
|
||
VALUE rb_int_ge(VALUE x, VALUE y);
|
||
VALUE rb_int_pow(VALUE x, VALUE y);
|
||
VALUE rb_float_pow(VALUE x, VALUE y);
|
||
VALUE rb_int_cmp(VALUE x, VALUE y);
|
||
VALUE rb_int_equal(VALUE x, VALUE y);
|
||
VALUE rb_int_fdiv(VALUE x, VALUE y);
|
||
VALUE rb_int_lshift(VALUE x, VALUE y);
|
||
VALUE rb_int_div(VALUE x, VALUE y);
|
||
VALUE rb_int_abs(VALUE num);
|
||
#if USE_FLONUM
|
||
#define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
|
numeric.c | ||
---|---|---|
static VALUE fix_lshift(long, unsigned long);
|
||
static VALUE fix_rshift(long, unsigned long);
|
||
static VALUE int_pow(long x, unsigned long y);
|
||
static VALUE int_cmp(VALUE x, VALUE y);
|
||
static int int_round_zero_p(VALUE num, int ndigits);
|
||
VALUE rb_int_floor(VALUE num, int ndigits);
|
||
VALUE rb_int_ceil(VALUE num, int ndigits);
|
||
... | ... | |
* 2.0**3 #=> 8.0
|
||
*/
|
||
static VALUE
|
||
flo_pow(VALUE x, VALUE y)
|
||
VALUE
|
||
rb_float_pow(VALUE x, VALUE y)
|
||
{
|
||
double dx, dy;
|
||
if (RB_TYPE_P(y, T_FIXNUM)) {
|
||
... | ... | |
h = rb_int_idiv(f, INT2FIX(2));
|
||
r = rb_int_modulo(num, f);
|
||
n = rb_int_minus(num, r);
|
||
r = int_cmp(r, h);
|
||
r = rb_int_cmp(r, h);
|
||
if (FIXNUM_POSITIVE_P(r) || (FIXNUM_ZERO_P(r) && !int_neg_p(num))) {
|
||
n = rb_int_plus(n, f);
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
static VALUE
|
||
int_fdiv(VALUE x, VALUE y)
|
||
VALUE
|
||
rb_int_fdiv(VALUE x, VALUE y)
|
||
{
|
||
if (FIXNUM_P(x)) {
|
||
return fix_fdiv(x, y);
|
||
... | ... | |
}
|
||
}
|
||
static VALUE
|
||
VALUE
|
||
rb_int_pow(VALUE x, VALUE y)
|
||
{
|
||
if (FIXNUM_P(x)) {
|
||
... | ... | |
}
|
||
}
|
||
static VALUE
|
||
int_equal(VALUE x, VALUE y)
|
||
VALUE
|
||
rb_int_equal(VALUE x, VALUE y)
|
||
{
|
||
if (FIXNUM_P(x)) {
|
||
return fix_equal(x, y);
|
||
... | ... | |
return rb_num_coerce_cmp(x, y, id_cmp);
|
||
}
|
||
static VALUE
|
||
int_cmp(VALUE x, VALUE y)
|
||
VALUE
|
||
rb_int_cmp(VALUE x, VALUE y)
|
||
{
|
||
if (FIXNUM_P(x)) {
|
||
return fix_cmp(x, y);
|
||
... | ... | |
return LONG2NUM(val);
|
||
}
|
||
static VALUE
|
||
VALUE
|
||
rb_int_lshift(VALUE x, VALUE y)
|
||
{
|
||
if (FIXNUM_P(x)) {
|
||
... | ... | |
return LONG2NUM(i);
|
||
}
|
||
static VALUE
|
||
int_abs(VALUE num)
|
||
VALUE
|
||
rb_int_abs(VALUE num)
|
||
{
|
||
if (FIXNUM_P(num)) {
|
||
return fix_abs(num);
|
||
... | ... | |
rb_define_method(rb_cInteger, "ceil", int_ceil, -1);
|
||
rb_define_method(rb_cInteger, "truncate", int_truncate, -1);
|
||
rb_define_method(rb_cInteger, "round", int_round, -1);
|
||
rb_define_method(rb_cInteger, "<=>", int_cmp, 1);
|
||
rb_define_method(rb_cInteger, "<=>", rb_int_cmp, 1);
|
||
rb_define_method(rb_cInteger, "-@", rb_int_uminus, 0);
|
||
rb_define_method(rb_cInteger, "+", rb_int_plus, 1);
|
||
... | ... | |
rb_define_method(rb_cInteger, "modulo", rb_int_modulo, 1);
|
||
rb_define_method(rb_cInteger, "remainder", int_remainder, 1);
|
||
rb_define_method(rb_cInteger, "divmod", int_divmod, 1);
|
||
rb_define_method(rb_cInteger, "fdiv", int_fdiv, 1);
|
||
rb_define_method(rb_cInteger, "fdiv", rb_int_fdiv, 1);
|
||
rb_define_method(rb_cInteger, "**", rb_int_pow, 1);
|
||
rb_define_method(rb_cInteger, "abs", int_abs, 0);
|
||
rb_define_method(rb_cInteger, "magnitude", int_abs, 0);
|
||
rb_define_method(rb_cInteger, "abs", rb_int_abs, 0);
|
||
rb_define_method(rb_cInteger, "magnitude", rb_int_abs, 0);
|
||
rb_define_method(rb_cInteger, "===", int_equal, 1);
|
||
rb_define_method(rb_cInteger, "==", int_equal, 1);
|
||
rb_define_method(rb_cInteger, "===", rb_int_equal, 1);
|
||
rb_define_method(rb_cInteger, "==", rb_int_equal, 1);
|
||
rb_define_method(rb_cInteger, ">", int_gt, 1);
|
||
rb_define_method(rb_cInteger, ">=", rb_int_ge, 1);
|
||
rb_define_method(rb_cInteger, "<", int_lt, 1);
|
||
... | ... | |
rb_define_method(rb_cFloat, "%", flo_mod, 1);
|
||
rb_define_method(rb_cFloat, "modulo", flo_mod, 1);
|
||
rb_define_method(rb_cFloat, "divmod", flo_divmod, 1);
|
||
rb_define_method(rb_cFloat, "**", flo_pow, 1);
|
||
rb_define_method(rb_cFloat, "**", rb_float_pow, 1);
|
||
rb_define_method(rb_cFloat, "==", flo_eq, 1);
|
||
rb_define_method(rb_cFloat, "===", flo_eq, 1);
|
||
rb_define_method(rb_cFloat, "<=>", flo_cmp, 1);
|