Ruby Float phase() method with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Float phase() is a float class method which works on float values and works differently for both positive and negative values. Syntax: float.phase() Parameter: float value which is to be checked Return: return 0 for positive values otherwise return pi(3.141592653589793) Example #1: Ruby # Ruby code for phase() method # Initializing value a = -100.7 - 10.4 b = -100 * 2000.0 c = (22 + 7.1) * 4 # Printing result puts "phase value of a : #{a.phase}\n\n" puts "phase value of b : #{b.phase}\n\n" puts "phase value of c : #{c.phase}\n\n" Output : phase value of a : 3.141592653589793 phase value of b : 3.141592653589793 phase value of c : 0 Example #2: Ruby # Ruby code for phase() method # Initializing value a = -56.23333333 b = 10000.0 c = -(22 + 7.1) # Printing result puts "phase value of a : #{a.phase}\n\n" puts "phase value of b : #{b.phase}\n\n" puts "phase value of c : #{c.phase}\n\n" Output : phase value of a : 3.141592653589793 phase value of b : 0 phase value of c : 3.141592653589793 Comment More infoAdvertise with us Next Article Ruby Float phase() method with example M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads Ruby Float nan?() method with example Float nan?() is a float class method that checks whether the value is 'not a number'. 'Not A Number' means an invalid IEEE floating-point number. Syntax: float.nan?()Parameter: float value to be passedReturn: Return true - if the value is 'not a number' otherwise return false Example #1:Â Â Ruby # Ru 1 min read Ruby Float to_r() method with example Float to_r() is a float class method which return a rational form of the float value. Syntax: float.to_r() Parameter: float value as argument Return: Rational form representation of the float value. Example #1 : Ruby # Ruby code for to_r() method # Initializing values a = 2.0 b = 9.99991 # Printing 1 min read Ruby Float arg() method with example Float arg() is a float class method which works on float values and works differently for both positive and negative values. Syntax: float.arg() Parameter: float value which is to be checked Return: return 0 for positive values. Otherwise pi(3.141592653589793) Example #1: Ruby # Ruby code for arg() 1 min read Ruby Float rationalize() method with example Float rationalize() is a float class method which return the simple rational form (p/q) of a float value. Syntax: float.rationalize() Parameter: float value as argument Return: Simple approximation value Example #1: Ruby # Ruby program for rationalize() method # Initialize value a = 0.767 b = 2999.0 1 min read Ruby Float zero?() method with example Float#zero() : zero() is a float class method which checks whether the float value is zero. Syntax: float.zero() Parameter:float value which is to be checked Return: Boolean value return true if value is zero otherwise return false Example #1: Ruby # Ruby code for zero?() method # Initializing value 1 min read Like