Ruby | Numeric numerator() function Last Updated : 19 Mar, 2024 Comments Improve Suggest changes Like Article Like Report 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 # Prints the numerator puts num1.numerator() Output: 12 Example 2: Ruby # Ruby program for numerator() # method in Numeric # Initialize a number num1 = 1.5 # Prints the numerator puts num1.numerator() Output: 3 Comment More infoAdvertise with us Next Article Ruby | Numeric numerator() function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads 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 negative? function The negative?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is a negative one, else it returns false. Syntax: num.negative?() Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value. Example 1: CPP # 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 | Rational numerator() function The numerator() is an inbuilt function in Ruby returns the numerator. Syntax: rat.numerator() Parameters: The function accepts no parameter Return Value: It returns the numerator Example 1: Ruby # Ruby program for numerator() method # Initialize rational number rat1 = Rational(7, -3) # Prints the ra 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 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 modulo() function 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 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 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 imaginary() function The imaginary() is an inbuilt method in Ruby returns the imaginary part of the given number. Syntax: num.imaginary() Parameters: The function needs a number whose imaginary part is to be returned. Return Value: It returns the imaginary part. Example 1: CPP # Ruby program for imaginary() # method in 1 min read Like