Ruby Integer floor() function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The ceil function in Ruby returns the smallest number smaller than or equal to int with a precision of ndigits decimal digits. The default is considered to be 0. When the precision given is negative, the returned value is an integer with at least ndigits.abs trailing zeros. It returns self when ndigits positive. Syntax: (number).floor(ndigits) Parameter: The function takes the integer whose floor value is to be returned and a single parameter ndigits which specifies the precision to be returned. Return Value: The function returns the smallest integer number smaller than or equal to it. Example #1: Ruby # Ruby program of Integer floor() function # Initializing the numbers num1 = 10 num2 = 17 num3 = 17.5 num4 = 21.5 # Prints the floor value puts num1.floor puts num2.floor(2) puts num3.floor(-1) puts num4.floor(0) Output: 10 17.0 10 21 Example #2: Ruby # Ruby program of Integer floor() function # Initializing the numbers num1 = 13 num2 = -90 num3 = 90 num4 = 81.7 # Prints the floor value puts num1.floor puts num2.floor(2) puts num3.floor(-1) puts num4.floor(0) Output: 13 -90 90 81 Comment More infoAdvertise with us Next Article Ruby Integer floor() function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer fdiv() function with example The fdiv() function in Ruby returns the floating point result after division of two numbers. Syntax: (number1).fdiv(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the floating point 1 min read Ruby Integer to_f function with example The to_f function in Ruby converts the value of the number as a float. If it does not fit in float, then it returns infinity. Syntax: number.to_f Parameter: The function takes the integer which is to be converted to float. Return Value: The function returns the float value of the number. Example #1: 1 min read Ruby Integer div() function with example The div() function in Ruby returns the integer division of two numbers. Syntax: (number1).div(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the integer division of two numbers. Exam 1 min read Ruby Integer gcd() function with example The gcd() function in Ruby returns the gcd of two numbers. GCD signifies the greatest common divisor which divides both the numbers. Syntax: number1.gcd(number2) Parameter: The function requires two numbers whose gcd is to be returned. Return Value: The function returns the gcd of two numbers Exampl 1 min read Ruby Integer abs() function with example The abs() function in Ruby returns the absolute value of the integer. Syntax: (number).abs Parameter: The function takes the integer whose absolute value is to be returned. Return Value: The function returns the absolute value of the integer. Example #1: Ruby # Ruby program Integer abs() function # 1 min read Like