operator + method
Returns a Complex
whose value is
(this + addend)
.
Uses the definitional formula
(a + bi) + (c + di) = (a+c) + (b+d)i
If either this
or addend
has a NaN
value in
either part, NaN
is returned; otherwise Infinite
and nan values are returned in the parts of the result
according to the rules for double arithmetic.
Implementation
@override
Cartesian operator +(Object addend) {
if (isNaN) return Complex.nan;
if (addend is Complex) {
if (addend.isNaN) return Complex.nan;
return Cartesian(real + addend.real, imaginary + addend.imaginary);
} else if (addend is num) {
if (addend.isNaN) return Complex.nan;
return Cartesian(real + addend, imaginary);
} else {
throw ArgumentError('factor must be a num or a Complex');
}
}