Ruby Integer digits function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 takes a non-mandatory parameter base to which the conversion is to be done. The minimum value in the base can be 2. Return Value: The function returns the digits place in new line after conversion. Example #1: Ruby # Ruby program of Integer digits function # Initializing the numbers num1 = 6788 num2 = 89 # Prints the number # after base conversion puts num1.digits puts puts num2.digits(3) Output: 8 8 7 6 2 2 0 0 1 Example #2: Ruby # Ruby Program of Integer digits function # Initializing the numbers num1 = 563 num2 = 12 # Prints the number # after base conversion puts num1.digits puts puts num2.digits(6) Output: 3 6 5 0 2 Comment More infoAdvertise with us Next Article Ruby Integer digits function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads 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 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 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 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 ceil function with example The ceil function in Ruby returns the smallest number greater 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 ndig 1 min read Like