Open In App

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

Next Article

Similar Reads