Ruby | Numeric phase() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share 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 Comment More infoAdvertise with us Next Article Ruby | Numeric positive? function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads Ruby | Numeric positive? function The positive?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is a positive one, else it returns false. Syntax: num.positive?()Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value. Example 1: CPP # 1 min read Ruby | Numeric real() function The real() is an inbuilt method in Ruby returns the real part of the given number. Syntax: num.real() Parameters: The function needs the number whose real part is to be returned. Return Value: It returns the real part of the complex number. Example 1: Ruby # Ruby program for real() # method in Numer 1 min read Ruby | Numeric rect() function The rect() is an inbuilt method in Ruby returns an array which consists of a real and an imaginary number. Syntax: num.rect() Parameters: The function needs the number whose real and imaginary part is returned. Return Value: It returns an array which consists of a real and an imaginary number. Examp 1 min read Ruby | Numeric real? function The real?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is a negative one, else it returns false. Syntax: num.real?() Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value. Example 1: CPP # Ruby pr 1 min read Ruby | Numeric quo() function The quo() is an inbuilt method in Ruby returns the most exact division, whether it be a float or a rational one. Syntax: num.quo() Parameters: The function needs a number which is to be checked. Return Value: It returns the most exact division. Example 1: Ruby # Ruby program for quo() # method in Nu 1 min read Ruby | Numeric i() function The i() is an inbuilt method in Ruby returns a complex number with the imaginary part that is given. Syntax: num.i() Parameters: The function needs a number which is the imaginary part of the complex number. Return Value: It returns a complex number with the imaginary part. Example 1: CPP # Ruby pro 1 min read Like