VOOZH about

URL: https://www.geeksforgeeks.org/ruby/ruby-float-round-method-with-example/

⇱ Ruby Float round() method with example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby Float round() method with example

Last Updated : 8 Jan, 2020
round() is a float class method which return a float value rounded to the nearest value with n digits decimal digits precision.
Syntax: float.round() Parameter: float value as argument Return: Float value rounded to nearest precision If precision is -ve : integer with at least ndigits.abs trailing zeros If ndigits is +ve : a floating-point number, otherwise integer
Example #1 : Output :
rounding a : 1

rounding b : 2999

Example #2 : Output :
round a : 0.77

round b : 3000

round c : 2
Comment
Article Tags: