Ruby Float angle() method with example
Float angle() is a float class method which works on float values and works differently for both positive and negative values.
Syntax: float.angle()
Parameter: float value which is to be checked
Return: 0 for positive values Otherwise pi(3.141592653589793)
Example #1 :
# Ruby code for angle() method # Initializing valuea = -100.7 - 10.4b = -100 * 2000.0c = (22 + 7.1) * 4 # Printing resultputs "angle value of a : #{a.angle}\n\n"puts "angle value of b : #{b.angle}\n\n"puts "angle value of c : #{c.angle}\n\n" |
Output :
angle value of a : 3.141592653589793 angle value of b : 3.141592653589793 angle value of c : 0
Example #2 :
# Ruby code for angle() method # Initializing valuea = -56.23333333b = 10000.0c = -(22 + 7.1) # Printing resultputs "angle value of a : #{a.angle}\n\n"puts "angle value of b : #{b.angle}\n\n"puts "angle value of c : #{c.angle}\n\n" |
Output :
angle value of a : 3.141592653589793 angle value of b : 0 angle value of c : 3.141592653589793


