Forum: Ruby on Rails making an integer from a float

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sean C. (Guest)
on 2006-04-06 13:29
Does anybody know how to turn a floating-point number (i.e. 60.345) into
an integer by cutting off or rounding the decimal portion? Either
method, or both, would be quite welcome. Thanks! This forum rocks!
Henry T. (Guest)
on 2006-04-06 13:34
(Received via mailing list)
Yeah #to_i is what youre looking for.

Linda D. (Guest)
on 2006-04-06 13:53
(Received via mailing list)
Float.round will return the floor or ceil appropriately.
This topic is locked and can not be replied to.