Ruby | Numeric div() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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() method in Matrix #Initialize a number num1 = 15 #Prints division of num1 / 4 puts num1.div(4) Output: 3Example 2: CPP #Ruby program for div() method in Matrix #Initialize a number num1 = 20 #Prints division of num1 / 2 puts num1.div(2) Output: 10 Comment More infoAdvertise with us Next Article Ruby | Numeric ceil() 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 divmod() function The divmod() is an inbuilt method in Ruby returns the integer quotient and modulus after performing the division. Syntax: num1.divmod(num2) Parameters: The function needs two numbers whose integer division is to be performed. Return Value: It returns returns the integer quotient and modulus after pe 1 min read Ruby | Numeric dup() function The dup() is an inbuilt method in Ruby returns the number itself. Syntax: num1.dup() Parameters: The function needs a number. Return Value: It returns itself only. Example 1:  Ruby # Ruby program for dup() method in Numeric # Initialize a number num1 = 1.7 # Function used num = num1.dup() # Prints 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 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 Ruby | Numeric i() function The i() is an inbuilt method in Ruby returns a complex number with the imaginary part that is given. Syntax: num.i() Parameters: The function needs a number which is the imaginary part of the complex number. Return Value: It returns a complex number with the imaginary part. Example 1: CPP # Ruby pro 1 min read Like