How do you round a float to 2 decimal places in JRuby?

Sam picture Sam · May 5, 2012 · Viewed 237.7k times · Source

How do you round a float to 2 decimal places in JRuby(1.6.x)?

number = 1.1164
number.round(2)

# The above shows the following error
# wrong number of arguments (1 for 0)

Answer

boulder_ruby picture boulder_ruby · Feb 28, 2013
(5.65235534).round(2)
#=> 5.65