Ruby | Numeric imaginary() function
The imaginary() is an inbuilt method in Ruby returns the imaginary part of the given number.
Syntax: num.imaginary()
Parameters: The function needs a number whose imaginary part is to be returned.
Return Value: It returns the imaginary part.
Example 1:
# Ruby program for imaginary() # method in Numeric # Initialize a number num1 = Complex(10, 9) # Prints Imaginary number puts num1.imaginary() |
chevron_right
filter_none
Output:
9
Example 2:
# Ruby program for imaginary() # method in Numeric # Initialize a number num1 = Complex(10, 0) # Prints Imaginary number puts num1.imaginary() |
chevron_right
filter_none
Output:
0
Recommended Posts:
- Ruby | Matrix imaginary() function
- Ruby | Numeric dup() function
- Ruby | Numeric eql?() function
- Ruby | Numeric arg() function
- Ruby | Numeric abs() function
- Ruby | Numeric quo() function
- Ruby | Numeric div() function
- Ruby | Numeric i() function
- Ruby | Numeric zero? function
- Ruby | Numeric ceil() function
- Ruby | Numeric nonzero? function
- Ruby | Numeric phase() function
- Ruby | Numeric infinite? function
- Ruby | Numeric floor() function
- Ruby | Numeric abs2() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



