Horje
Ruby | Numeric denominator() function

The denominator() is an inbuilt method in Ruby returns the denominator of the number.

Syntax: num1.denominator()

Parameters: The function needs a number whose denominator is returned.

Return Value: It returns itself only.

Example 1:




# Ruby program for denominator() method in Matrix
  
# Initialize a number 
num1 = 1.5
  
# Function used
num = num1.denominator()
  
# Prints denominator() of num
puts num

Output:

2

Example 2:




# Ruby program for denominator() method in Matrix
  
# Initialize a number 
num1 = 155
  
# Function used
num = num1.denominator()
  
# Prints denominator() of num
puts num

Output:

1



Reffered: https://www.geeksforgeeks.org


Ruby

Related
Ruby | Numeric div() function Ruby | Numeric div() function
Ruby | Numeric divmod() function Ruby | Numeric divmod() function
Ruby | Numeric eql?() function Ruby | Numeric eql?() function
Ruby | Time succ() function Ruby | Time succ() function
Ruby | Time subsec() function Ruby | Time subsec() function

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
10