Ruby | Numeric ceil() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The ceil() is an inbuilt method in Ruby returns the smallest number which is greater than or equal to the given number by keeping a precision of n digits of the decimal part. Syntax: num.ceil(n digits) Parameters: The function needs a number and n digits to which the precision of decimal digits is kept. In case no n digits is passed it takes 0 to be the default value. Return Value: It returns the smallest number which is greater than or equal to the given number by keeping a precision of n digits of the decimal part. Example 1: Ruby # Ruby program for ceil() method in Numeric # Initialize a number num1 = -19 num2 = -18.97 num3 = 18.98 # Prints ceil() of num puts num1.ceil() puts num2.ceil() puts num3.ceil() Output: -19 -18 19 Example 2: Ruby # Ruby program for ceil() method in Numeric # Initialize a number num1 = -19.897 num2 = -18.321 num3 = 190.23213 # Prints ceil() of num puts num1.ceil(1) puts num2.ceil(2) puts num3.ceil(3) Output: -19.8 -18.32 190.233 Comment More infoAdvertise with us Next Article Ruby | Numeric conj() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads Ruby | Numeric eql?() function The eql?() is an inbuilt method in Ruby returns a boolean value. It returns true if both the numbers are equal, else it returns false. Syntax: num1.eql?(num2) Parameters: The function needs two number whose comparison is to be done. Return Value: It returns returns true if both are equal, else it r 1 min read Ruby | Numeric div() function The div() is an inbuilt method in Ruby that returns the result after performing an integer division. Syntax: num1.div(num2) Parameters: The function needs two numbers whose integer division is to be performed. Return Value: It returns returns the integer division.Example 1: CPP #Ruby program for div 1 min read Ruby | Numeric coerce() function The coerce() is an inbuilt method in Ruby returns an array containing two numbers containing two float numbers. Syntax: num1.coerce(num2) Parameters: The function needs a number and ndigits to which the precision of decimal digits is kept. In case no ndigits is passed it takes 0 to be the default v 1 min read Ruby | Numeric conj() function The conj() is an inbuilt method in Ruby returns the number itself. Syntax: num1.conj() Parameters: The function needs a number. Return Value: It returns itself only. Example 1:  Ruby # Ruby program for conj() method in Numeric # Initialize a number num1 = 1.7 # Function used num = num1.conj() # P 1 min read Ruby | Numeric to_c() function The to_c() is an inbuilt method in Ruby returns a complex number with the num. Syntax: num.to_c() Parameters: The function needs the number which is to be returned as complex. Return Value: It returns the complex number. Example 1: Ruby # Ruby program for to_c() # method in Numeric # Initialize a nu 1 min read Ruby | Numeric fdiv() function The fdiv() is an inbuilt method in Ruby returns the result after performing a float division. Syntax: num1.fdiv(num2) Parameters: The function needs two numbers whose float division is to be performed. Return Value: It returns returns the float division. Example 1: CPP # Ruby program for fdiv() meth 1 min read Like