public Method

Float.floor

flt.floor    integer

Returns the largest integer less than or equal to flt.

1.2.floor      #=> 1
2.0.floor      #=> 2
(-1.2).floor   #=> -2
(-2.0).floor   #=> -2

Source Code

/*
*  call-seq:
*     flt.floor   => integer
*  
*  Returns the largest integer less than or equal to <i>flt</i>.
*     
*     1.2.floor      #=> 1
*     2.0.floor      #=> 2
*     (-1.2).floor   #=> -2
*     (-2.0).floor   #=> -2
*/

static VALUE
flo_floor(num)
   VALUE num;
{
   double f = floor(RFLOAT(num)->value);
   long val;

   if (!FIXABLE(f)) {
       return rb_dbl2big(f);
   }
   val = f;
   return LONG2FIX(val);
}
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.