Open In App

Ruby | Numeric phase() function

Last Updated : 19 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report
The phase() is an inbuilt method in Ruby returns 0 if the value is positive, else it returns a float value pi.
Syntax: num.phase() Parameters: The function needs a number which is to be checked. Return Value: It returns zero if the value is positive, else it returns a float value pi.
Example 1: Ruby
# Ruby program for phase()
# method in Numeric

# Initialize a number 
num1 = 10

# Prints the phase
puts num1.phase()
Output:
0
Example 2: Ruby
# Ruby program for phase()
# method in Numeric

# Initialize a number 
num1 = -10

# Prints the phase
puts num1.phase()
Output:
3.141592653589793

Next Article

Similar Reads