Blog post

Complex number

25/01/2016 1 min read

Since a complex number is comprised of a real and imaginary component, two complex numbers are equal if and only if their respective real and imaginary components are equal.

Complex number

Complex.swift {% highlight swift %} struct Complex<T: SignedNumberType> { let real: T let imaginary: T } {% endhighlight %}

{% highlight swift %} extension Complex: Equatable {}

// MARK: Equatable

func ==(lhs: Complex, rhs: Complex) -> Bool { return lhs.real == rhs.real && lhs.imaginary == rhs.imaginary } {% endhighlight %}