Forum: Ruby on Rails making an integer from a float

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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.

http://www.ruby-doc.org/docs/ProgrammingRuby/

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