to_int()
public
Returns flt truncated to an Integer.
Show source
/*
* call-seq:
* flt.to_i => integer
* flt.to_int => integer
* flt.truncate => integer
*
* Returns <i>flt</i> truncated to an <code>Integer</code>.
*/
static VALUE
flo_truncate(num)
VALUE num;
{
double f = RFLOAT(num)->value;
long val;
if (f > 0.0) f = floor(f);
if (f < 0.0) f = ceil(f);
if (!FIXABLE(f)) {
return rb_dbl2big(f);
}
val = f;
return LONG2FIX(val);
}