Open In App

Ruby | Numeric angle() function

Improve
Improve
Like Article
Like
Save
Share
Report

The angle() is an inbuilt method in Ruby returns 0 if the number is positive, else it returns a float value which is equal to pi. 

Syntax: num.angle()

Parameters: The function needs a number. 

Return Value: It returns 0 if the number is positive, else it returns a float value which is equal to pi. .

Example 1:  

Ruby




# Ruby program for angle() method in Numeric
  
# Initialize a number 
num = -19 
  
# Prints angle() of num
puts  num.angle() 


Output

3.141592653589793

Example 2

Ruby




# Ruby program for angle() method in Numeric
  
# Initialize a number 
num = 100
  
# Prints angle() of num
puts  num.angle() 


Output

0

 


Last Updated : 19 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads