Ruby | Numeric modulo() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The modulo() is an inbuilt method in Ruby returns the modular value when two numbers are divided. It returns the value of a modulo b. Syntax: a.modulo(b) Parameters: The function needs two number whose modulus on division is returned. Return Value: It returns the modulus when two numbers are divided. Example 1: CPP # Ruby program for % method in Matrix # Initialize two numbers a = 19 b = 4 # Prints a % b puts a.modulo(b) Output: 3 Example 2: CPP # Ruby program for modulo() method in Matrix # Initialize two numbers a = 13 b = 2 # Prints a % b puts a.modulo(b) Output: 1 Comment More infoAdvertise with us Next Article Ruby | Numeric modulo() function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads 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 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 nonzero? function The nonzero?() is an inbuilt method in Ruby returns self if the number is non-zero, else it returns nil. Syntax: num.nonzero?() Parameters: The function needs a number which is to be checked. Return Value: It returns self or nil. Example 1: Ruby # Ruby program for nonzero? # method in Numeric # Init 1 min read Ruby | Numeric magnitude() function The magnitude() is an inbuilt method in Ruby returns the magnitude of a number. Syntax: num.magnitude Parameters: The function needs the number whose magnitude is to be returned. Return Value: It returns the magnitude of a number. Example 1:  Ruby # Ruby program for magnitude() method in Numeric 1 min read Ruby | Numeric numerator() function The numerator() is an inbuilt method in Ruby returns the numerator. Syntax: num.numerator() Parameters: The function needs a number which is to be checked. Return Value: It returns self or nil. Example 1: Ruby # Ruby program for numerator() # method in Numeric # Initialize a number num1 = 3.5 # Prin 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 quo() function The quo() is an inbuilt method in Ruby returns the most exact division, whether it be a float or a rational one. Syntax: num.quo() Parameters: The function needs a number which is to be checked. Return Value: It returns the most exact division. Example 1: Ruby # Ruby program for quo() # method in Nu 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 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 eql?() function The eql?() is an inbuilt method in Ruby returns a boolean value. It returns true if both the numbers are equal, else it returns false. Syntax: num1.eql?(num2) Parameters: The function needs two number whose comparison is to be done. Return Value: It returns returns true if both are equal, else it r 1 min read Like