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.
241b11f59c4bcfc2ce84a43f52b30001?d=identicon&s=25 Sean Cahoon (osakaboy)
on 2006-04-06 11: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!
6cf8286fcab5843f468d62f5e6fb22de?d=identicon&s=25 Henry Turner (Guest)
on 2006-04-06 11:34
(Received via mailing list)
Yeah #to_i is what youre looking for.

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

-h
441a4d55a7d1a4c79a6f472aa7e77c38?d=identicon&s=25 Linda Derezinski (Guest)
on 2006-04-06 11: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.