Or round a number up or down (Float, Integer, or Numeric): : Numeric class « Number « Ruby






Or round a number up or down (Float, Integer, or Numeric):


100.45.round # => 100
100.49.round # => 100
100.5.round # => 101
100.6.round # => 101

 








Related examples in the same category

1.The integer? method comes from the Numeric class
2.Is a number integer
3.More Math Methods
4.Get the ceiling or floor of a number (from Float, Integer, or Numeric):
5.Get the next integer with next (or its alias succ):
6.Find out the modules Numeric class resides