The round() is an inbuilt method in Ruby returns a number rounded to a number nearest to the given number with a precision of the given number of digits after the decimal point. In case the number of digits is not given, the default value is taken to be zero.
Parameters: The function needs a number and ndigits which specifies the number of digits to be rounded off. If ndigits is not given then, default value is taken to be zero.
Return Value: It returns the rounded value.
-16.8 -17 17
12.3 -1322.0 -12.232
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.