Ruby Float floor() method with example Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report floor() is a float class method which return the floor value of the passed float value. Syntax: float.floor() Parameter: float value which is to get its floor value decimal digits (default = 0) Return: smallest number >= to float with a ndigits decimal point precision. For -ve precision : Integer with at least ndigits.abs trailing zeros. For +ve precision : Floating point number. Example #1: Ruby # Ruby code for floor() method a = -56.23333333 b = 56.784 c = 222.8868686 # Printing result puts "floor value of a : #{a.floor}\n\n" puts "floor value of b : #{b.floor}\n\n" puts "floor value of c : #{c.floor}\n\n" Output : floor value of a : -57 floor value of b : 56 floor value of c : 222 Example #2: Ruby # Ruby code for floor() method a = -0.78779393 b = -50006.784 + 34 c = 289 + 22.8868686 # Printing result puts "floor value of a : #{a.floor}\n\n" puts "floor value of b : #{b.floor}\n\n" puts "floor value of c : #{c.floor}\n\n" Output : floor value of a : -1 floor value of b : -49973 floor value of c : 311 Comment More infoAdvertise with us Next Article Ruby Float floor() method with example M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads Ruby Float next_float() method with example Float next_float() is a float class method which returns the next representation of the floating point number. Syntax: float.next_float() Parameter: float value to be passed Return: Next representation of the floating point number. Example #1: Ruby # Ruby program for next_float() method # Initializi 1 min read Ruby Float quo() method with example Float quo() is a float class method which return the quotient value of the division. Syntax: float.quo() Parameter: float values - dividend and divisor Return: Quotient value of the division. Example #1: Ruby # Ruby code for quo() method # Initializing value a = 4.0 b = 2.0 # Printing result puts 1 min read Ruby Float fdiv() method with example Float fdiv() is a float class method which return a division value of the form p/q. Syntax: float.fdiv() Parameter: values to divide - p and q Return: Division value - Quotient Example #1: Ruby # Ruby program for fdiv() method # Initializing value a = 2.0.numerator() # returning machine dependent re 1 min read Ruby Float to_r() method with example Float to_r() is a float class method which return a rational form of the float value. Syntax: float.to_r() Parameter: float value as argument Return: Rational form representation of the float value. Example #1 : Ruby # Ruby code for to_r() method # Initializing values a = 2.0 b = 9.99991 # Printing 1 min read Ruby Float zero?() method with example Float#zero() : zero() is a float class method which checks whether the float value is zero. Syntax: float.zero() Parameter:float value which is to be checked Return: Boolean value return true if value is zero otherwise return false Example #1: Ruby # Ruby code for zero?() method # Initializing value 1 min read Like