public Method

Float.abs

flt.abs     float

Returns the absolute value of flt.

(-34.56).abs   #=> 34.56
-34.56.abs     #=> 34.56

Source Code

/*
*  call-seq:
*     flt.abs    => float
*  
*  Returns the absolute value of <i>flt</i>.
*     
*     (-34.56).abs   #=> 34.56
*     -34.56.abs     #=> 34.56
*     
*/

static VALUE
flo_abs(flt)
   VALUE flt;
{
   double val = fabs(RFLOAT(flt)->value);
   return rb_float_new(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.