==(p1)
public
Returns true only if obj has the same value as
float. Contrast this with Float#eql?, which requires obj to be a
Float.
The result of NaN == NaN is undefined, so the implementation-dependent
value is returned.
1.0 == 1
Show source
static VALUE
flo_eq(VALUE x, VALUE y)
{
volatile double a, b;
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
return rb_integer_float_eq(y, x);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
b = RFLOAT_VALUE(y);
if (isnan(b)) return Qfalse;
}
else {
return num_equal(x, y);
}
a = RFLOAT_VALUE(x);
if (isnan(a)) return Qfalse;
return (a == b)?Qtrue:Qfalse;
}