to_int()
public
Returns the float truncated to an Integer.
1.2.to_i
(-1.2).to_i
Note that the limited precision of floating point arithmetic might lead to
surprising results:
(0.3 / 0.1).to_i
#to_int is an alias for #to_i.
Show source
static VALUE
flo_to_i(VALUE num)
{
double f = RFLOAT_VALUE(num);
if (f > 0.0) f = floor(f);
if (f < 0.0) f = ceil(f);
return dbl2ival(f);
}