Complex numbers
A complex number z = x + yi is the sum of a real number x and a real number y multiplied by the imaginary unit i, i 2 = -1 ⇒ i = ±√(-1) , which is the solution of the equation x 2 + 1 = 0.
Complex.h
namespace SmallWindows { class NotaComplexNumber : public exception { public: NotaComplexNumber() {/* Empty. */} }; extern double Square(double value);
The constructors, assignment operators, and the String
conversion operator are similar to their counterparts in Rational
:
class Complex { public: Complex(double x = 0, double y = 0); Complex(const Complex &complex); Complex operator=(const Complex &complex); bool ReadStream(const String& text); Complex(const String& text); operator String() const;
When comparing two complex number, their absolute values (refer to Abs
) are compared.
bool operator==(const Complex &complex) const; bool operator!=(const Complex...