Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Numeric numerator() function

  • Last Updated : 06 Jan, 2020

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 program for numerator()
# method in Numeric
  
# Initialize a number 
num1 = 3.5
  
# Prints the numerator
puts num1.numerator()

Output:

12

Example 2:




# Ruby program for numerator()
# method in Numeric
  
# Initialize a number 
num1 = 1.5
  
# Prints the numerator
puts num1.numerator()

Output:

3
My Personal Notes arrow_drop_up
Recommended Articles
Page :