Open In App

Ruby | Numeric numerator() function

Last Updated : 19 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
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 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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads