==(p1)
public
Show source
static VALUE
nurat_eqeq_p(VALUE self, VALUE other)
{
if (RB_INTEGER_TYPE_P(other)) {
{
get_dat1(self);
if (INT_ZERO_P(dat->num) && INT_ZERO_P(other))
return Qtrue;
if (!FIXNUM_P(dat->den))
return Qfalse;
if (FIX2LONG(dat->den) != 1)
return Qfalse;
return rb_int_equal(dat->num, other);
}
}
else if (RB_FLOAT_TYPE_P(other)) {
const double d = nurat_to_double(self);
return f_boolcast(FIXNUM_ZERO_P(rb_dbl_cmp(d, RFLOAT_VALUE(other))));
}
else if (RB_TYPE_P(other, T_RATIONAL)) {
{
get_dat2(self, other);
if (INT_ZERO_P(adat->num) && INT_ZERO_P(bdat->num))
return Qtrue;
return f_boolcast(rb_int_equal(adat->num, bdat->num) &&
rb_int_equal(adat->den, bdat->den));
}
}
else {
return rb_equal(other, self);
}
}