Ruby Integer div() function with example Last Updated : 25 Jun, 2020 Comments Improve Suggest changes Like Article Like Report 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. Example #1: CPP # Ruby program of Integer div() function # Initializing the numbers num1 = 5 num2 = 2 num3 = 9 num4 = 3 # Prints the integer division # value after performing division puts num1.div(num2) puts num3.div(num4) Output: 2 3 Example #2: CPP # Ruby program of Integer div() function # Initializing the numbers num1 = 15 num2 = 4 num3 = 10 num4 = 2 # Prints the integer division # value after performing division puts num1.div(num2) puts num3.div(num4) Output: 3 5 Comment More infoAdvertise with us Next Article Ruby Integer div() function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer divmod() function with example The divmod() function in Ruby returns integer division value and the remainder. Syntax: (number1).divmod(number2) Parameter: The function takes two number number1 and number2 whose integer division and remainder is returned. Return Value: The function returns the integer division value and the remai 1 min read Ruby Integer even? function with example The even? function in Ruby returns a boolean value. It returns true if the number is even, else it returns false. Syntax: number.even? Parameter: The function takes the integer which is to be checked for even or not. Return Value: The function returns a boolean value which determines if the value is 1 min read Ruby Integer digits function with example The digits function in Ruby returns the digits place of converting the number to the given base in the parameter. If there is no such parameter is provided, then the default base is taken as 10. Syntax: number.digits(base) Parameter: The function takes the integer whose conversion is to be done. It 1 min read Ruby Integer to_d() function with example The to_d function in Ruby converts the value of int as a BigDecimal. Syntax: number.to_d Parameter: The function takes the integer which is to be converted to BigDecimal. Return Value: The function returns the BigDecimal value of int. Example #1: Ruby # Ruby program for to_d function require 'bigdec 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