<=>(p1)
public
Comparison—Returns -1, 0, +1 or nil
depending on whether fix is less than, equal to, or greater than
numeric.
This is the basis for the tests in the Comparable module.
nil is returned if the two values are incomparable.
Show source
static VALUE
fix_cmp(VALUE x, VALUE y)
{
if (x == y) return INT2FIX(0);
if (FIXNUM_P(y)) {
if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1);
return INT2FIX(-1);
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
return rb_big_cmp(rb_int2big(FIX2LONG(x)), y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
return rb_integer_float_cmp(x, y);
}
else {
return rb_num_coerce_cmp(x, y, id_cmp);
}
}