Ruby | Numeric i() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 program for i() # method in Numeric # Initialize a number num1 = -10 # Prints Complex number puts num1.i() Output: 0-10i Example 2: CPP # Ruby program for i() # method in Numeric # Initialize a number num1 = 12 # Prints Complex number puts num1.i() Output: 0+12i Comment More infoAdvertise with us Next Article Ruby | Numeric to_int() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads Ruby | Numeric imag() function The imag() is an inbuilt method in Ruby returns the imag part of the given number. Syntax: num.imag() Parameters: The function needs a number whose imag part is to be returned. Return Value: It returns the imag part. Example 1: CPP # Ruby program for imag() # method in Numeric # Initialize a number 1 min read Ruby | Numeric to_int() function The to_int() is an inbuilt method in Ruby returns the integer part of the given number. Syntax: num.to_int() Parameters: The function needs the number whose integer part is to be returned. Return Value: It returns the integer part. Example 1: Ruby # Ruby program for to_int() # method in Numeric # In 1 min read Ruby | Numeric integer() function The integer?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is an integer one, else it returns false. Syntax: num.integer?() Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value. Example 1: CPP # R 1 min read Ruby | Numeric arg() function The arg() is an inbuilt method in Ruby returns 0 if the number is positive, else it returns a float value which is equal to pi. Syntax: num.arg() Parameters: The function needs a number. Return Value: It returns 0 if the number is positive, else it returns a float value which is equal to pi. . Exa 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 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 Like