type=class
superclass=Numeric
included=
extended=
dynamically_included=
dynamically_extended=
library=_builtin
aliases=
aliasof=

複素数を扱うクラスです。

[[c:Complex]] オブジェクトを作成するには、[[m:Kernel.#Complex]]、
[[m:Complex.rect]]、[[m:Complex.polar]]、[[m:Numeric#to_c]]、
[[m:String#to_c]] のいずれかを使用します。

  Complex(1)           # => (1+0i)
  Complex(2, 3)        # => (2+3i)
  Complex.polar(2, 3)  # => (-1.9799849932008908+0.2822400161197344i)
  Complex(0.3)         # => (0.3+0i)
  Complex('0.3-0.5i')  # => (0.3-0.5i)
  Complex('2/3+3/4i')  # => ((2/3)+(3/4)*i)
  Complex('1@2')       # => (-0.4161468365471424+0.9092974268256817i)
  3.to_c               # => (3+0i)
  0.3.to_c             # => (0.3+0i)
  '0.3-0.5i'.to_c      # => (0.3-0.5i)
  '2/3+3/4i'.to_c      # => ((2/3)+(3/4)*i)
  '1@2'.to_c           # => (-0.4161468365471424+0.9092974268256817i)

[[c:Complex]] オブジェクトは有理数の形式も実数の形式も扱う事ができます。

  Complex(1, 1) / 2    # => ((1/2)+(1/2)*i)
  Complex(1, 1) / 2.0  # => (0.5+0.5i)
