Ruby Float ceil() method with example Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report ceil() is a float class method which return the ceil value of the passed float value. Syntax: float.ceil() Parameter: float value which is to get its ceil 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 ceil() method # declaring float values a = -56.23333333 # declaring float values b = 56.784 # declaring float values c = 222.8868686 # ceil value of a puts "ceil value of a : #{a.ceil}\n\n" # ceil value of b puts "ceil value of b : #{b.ceil}\n\n" # ceil value of c puts "ceil value of c : #{c.ceil}\n\n" Output : ceil value of a : -56 ceil value of b : 57 ceil value of c : 223 Example #2 : Ruby # Ruby code for ceil() method # declaring float values a = -0.78779393 # declaring float values b = -50006.784 + 34 # declaring float values c = 289 + 22.8868686 # ceil value of a puts "ceil value of a : #{a.ceil}\n\n" # ceil value of b puts "ceil value of b : #{b.ceil}\n\n" # ceil value of c puts "ceil value of c : #{c.ceil}\n\n" Output : ceil value of a : 0 ceil value of b : -49972 ceil value of c : 312 Comment More infoAdvertise with us Next Article Ruby Float zero?() method with example M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads Ruby Float coerce() method with example coerce() is a float class method which return the ceil value of the passed float value. Syntax: float.coerce() Parameter: numeric values (can be integer as well as float value) Return: An array with both float and numeric value represented in the form of Float objects. Example #1 : Ruby # Ruby code 1 min read Ruby Float divmod() method with example Float divmod() is a float class method that returns an array having the quotient and remainder on dividing two numbers. Syntax: float.divmod()Parameter: float values - dividend and divisorReturn: An array with quotient and remainder. Example #1:Â Ruby # Ruby code for divmod() method # Initializing v 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 Ruby Float modulo() method with example Float modulo() is a float class method which return the remainder value on dividing two float values. Syntax: float.modulo() Parameter: remainder value from the operation p/q Return: Modulo i.e. Remainder Example #1: Example for modulo() method Ruby # Ruby program for modulo() method # Initilizig va 1 min read Ruby Float rationalize() method with example Float rationalize() is a float class method which return the simple rational form (p/q) of a float value. Syntax: float.rationalize() Parameter: float value as argument Return: Simple approximation value Example #1: Ruby # Ruby program for rationalize() method # Initialize value a = 0.767 b = 2999.0 1 min read Ruby CMath cbrt() Method with example cbrt method is a Math class method in Ruby which is used to calculate the cube root of the given value. Syntax: Math.cbrt(z) Parameter: Here, z is the value whose cube root is to be calculated. Returns: This method returns the cube root of the given number. Below programs illustrate the use of above 1 min read Like