Making an integer from a float

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!

Yeah #to_i is what youre looking for.


Float.round will return the floor or ceil appropriately.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs