==(p1)
public
Returns true only if obj has the same value as flt.
Contrast this with Float#eql?, which requires obj to be a Float.
1.0 == 1
Show source
/*
* call-seq:
* flt == obj => true or false
*
* Returns <code>true</code> only if <i>obj</i> has the same value
* as <i>flt</i>. Contrast this with <code>Float
* requires <i>obj</i> to be a <code>Float</code>.
*
* 1.0 == 1
*
*/
static VALUE
flo_eq(x, y)
VALUE x, y;
{
volatile double a, b;
switch (TYPE(y)) {
case T_FIXNUM:
b = FIX2LONG(y);
break;
case T_BIGNUM:
b = rb_big2dbl(y);
break;
case T_FLOAT:
b = RFLOAT(y)->value;
if (isnan(b)) return Qfalse;
break;
default:
return num_equal(x, y);
}
a = RFLOAT(x)->value;
if (isnan(a)) return Qfalse;
return (a == b)?Qtrue:Qfalse;
}