public Method

Float.finite?

flt.finite?  true or false

Returns true if flt is a valid IEEE floating point number (it is not infinite, and nan? is false).

Source Code

/*
*  call-seq:
*     flt.finite? -> true or false
*  
*  Returns <code>true</code> if <i>flt</i> is a valid IEEE floating
*  point number (it is not infinite, and <code>nan?</code> is
*  <code>false</code>).
*     
*/

static VALUE
flo_is_finite_p(num)
    VALUE num;
{     
   double value = RFLOAT(num)->value;

#if HAVE_FINITE
   if (!finite(value))
       return Qfalse;
#else
   if (isinf(value) || isnan(value))
       return Qfalse;
#endif

   return Qtrue;
}
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.