to_int()
public
Returns the float truncated to an Integer.
Synonyms are #to_i, #to_int, and #truncate.
Show source
static VALUE
flo_truncate(VALUE num)
{
double f = RFLOAT_VALUE(num);
long val;
if (f > 0.0) f = floor(f);
if (f < 0.0) f = ceil(f);
if (!FIXABLE(f)) {
return rb_dbl2big(f);
}
val = (long)f;
return LONG2FIX(val);
}