Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Complex denominator function

  • Last Updated : 07 Jan, 2020

Complex#denominator() : denominator() is a Complex class method which returns the denominator of the complex value.

Syntax: Complex.denominator()

Parameter: Complex values

Return: denominator of the complex value.

Example #1 :






# Ruby code for Complex.denominator() method
  
# declaring Complex value
a = Complex(200)
  
# declaring Complex value
b = Complex(-1, 4)
  
# declaring Complex value
c = Complex('i')
  
  
# use of denominator()  
puts "Complex denominator form : #{a.denominator}\n\n"
  
puts "Complex denominator form : #{b.denominator}\n\n"
  
puts "Complex denominator form : #{c.denominator}\n\n"

Output :

Complex denominator form : 1

Complex denominator form : 1

Complex denominator form : 1

Example #2 :




# Ruby code for Complex.denominator() method
  
# declaring Complex value
a = Complex(20, 90)
  
# declaring Complex value
b = Complex('i')
  
# declaring Complex value
c = Complex(100, -500)
  
  
# use of denominator()  
puts "Complex denominator form : #{a.denominator}\n\n"
  
puts "Complex denominator form : #{b.denominator}\n\n"
  
puts "Complex denominator form : #{c.denominator}\n\n"

Output :

Complex denominator form : 1

Complex denominator form : 1

Complex denominator form : 1




My Personal Notes arrow_drop_up
Recommended Articles
Page :