Ruby | Numeric floor() function Last Updated : 19 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The floor() is an inbuilt method in Ruby returns a number less than or equal to the given number with a precision of the given number of digits after the decimal point. In case the number of digits is not given, the default value is taken to be zero. Syntax: num.floor(ndigits) Parameters: The function needs a number and ndigits which specifies the number of digits to be round off. If ndigits is not given then, default value is taken to be zero. Return Value: It returns returns a boolean value. Example 1: CPP # Ruby program for floor() # method in Numeric # Initialize a number num1 = -16.7834 num2 = -16.78324 num3 = 16.873 # Prints floor puts num1.floor(1) puts num2.floor() puts num3.floor() Output: -16.8 -17 16 Example 2: CPP # Ruby program for floor() # method in Numeric # Initialize a number num1 = 12.32 num2 = -1321.998321 num3 = -12.2321 # Prints floor puts num1.floor(1) puts num2.floor(2) puts num3.floor(3) Output: 12.3 -1322.0 -12.233 Comment More infoAdvertise with us Next Article Ruby | Numeric floor() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads 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 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 ceil() function 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 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 abs() function The abs is an inbuilt method in Ruby returns the absolute value of a number.  Syntax: num.abs Parameters: The function needs the number whose absolute value is to be returned. Return Value: It returns the absolute value of a numbers. Example 1:  Ruby # Ruby program for abs() method in Numeric # I 1 min read Like