public Method

Float.eql?(p1)

flt.eql?(obj)    true or false

Returns true only if obj is a Float with the same value as flt. Contrast this with Float#==, which performs type conversions.

1.0.eql?(1)   #=> false

Source Code

/*
*  call-seq:
*     flt.eql?(obj)   => true or false
*  
*  Returns <code>true</code> only if <i>obj</i> is a
*  <code>Float</code> with the same value as <i>flt</i>. Contrast this
*  with <code>Float#==</code>, which performs type conversions.
*     
*     1.0.eql?(1)   #=> false
*/

static VALUE
flo_eql(x, y)
   VALUE x, y;
{
   if (TYPE(y) == T_FLOAT) {
       double a = RFLOAT(x)->value;
       double b = RFLOAT(y)->value;

       if (isnan(a) || isnan(b)) return Qfalse;
       if (a == b) return Qtrue;
   }
   return Qfalse;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.