Skip to content
Related Articles

Related Articles

Improve Article
Ruby | Numeric phase() function
  • Last Updated : 06 Jan, 2020

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 program for phase()
# method in Numeric
  
# Initialize a number 
num1 = 10
  
# Prints the phase
puts num1.phase()

Output:

0

Example 2:




# Ruby program for phase()
# method in Numeric
  
# Initialize a number 
num1 = -10
  
# Prints the phase
puts num1.phase()

Output:

3.141592653589793
My Personal Notes arrow_drop_up
Recommended Articles
Page :