user2993178 user2993178 - 2 years ago 69
Ruby Question

Ruby - get the floor of a float value?

How do I get the floor of a number like 188.50 to 188 in Ruby? I do not want to

the number up.

Answer Source

If you just want to truncate it, use to_i, if you want to round it use round:

> 188.51.to_i
=> 188

> 188.51.round
=> 189
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download