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 program for numerator() # method in Numeric # Initialize a number num1 = 3.5 # Prints the numerator puts num1.numerator() |
chevron_right
filter_none
Output:
12
Example 2:
# Ruby program for numerator() # method in Numeric # Initialize a number num1 = 1.5 # Prints the numerator puts num1.numerator() |
chevron_right
filter_none
Output:
3
Recommended Posts:
- Ruby | Rational numerator() function
- Ruby | Numeric eql?() function
- Ruby | Numeric dup() function
- Ruby | Numeric i() function
- Ruby | Numeric arg() function
- Ruby | Numeric abs() function
- Ruby | Numeric div() function
- Ruby | Numeric zero? function
- Ruby | Numeric quo() function
- Ruby | Numeric positive? function
- Ruby | Numeric nonzero? function
- Ruby | Numeric real? function
- Ruby | Numeric remainder() function
- Ruby | Numeric real() function
- Ruby | Numeric imag() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



