public Method

Float.infinite?

flt.infinite?  nil, -1, +1

Returns nil, -1, or +1 depending on whether flt is finite, -infinity, or +infinity.

(0.0).infinite?        #=> nil
(-1.0/0.0).infinite?   #=> -1
(+1.0/0.0).infinite?   #=> 1

Source Code

/*
*  call-seq:
*     flt.infinite? -> nil, -1, +1
*  
*  Returns <code>nil</code>, -1, or +1 depending on whether <i>flt</i>
*  is finite, -infinity, or +infinity.
*     
*     (0.0).infinite?        #=> nil
*     (-1.0/0.0).infinite?   #=> -1
*     (+1.0/0.0).infinite?   #=> 1
*/

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

   if (isinf(value)) {
       return INT2FIX( value < 0 ? -1 : 1 );
   }

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