Mathematical Operators for complex

The complex class defines a set of mathematical operators with the same precedence as the corresponding real operators. With the following operators, you can code expressions on complex numbers:

The complex mathematical assignment operators (+=, -=, *=, /=) do not produce a value that can be used in an expression. The following code, for example, produces a compile-time error:

   complex x, y, z; // valid declaration
   x = (y += z );   // invalid assignment causes
                    // a compile-time error

The equality and inequality operators test for an exact equality between the real parts of two numbers, and between their complex parts. Because both components are double values, two numbers may be “equal” within a certain tolerance, but unequal as far as these operators are concerned. If you want an equality or inequality operator that can test for an absolute difference within a certain tolerance between the two pairs of corresponding components, you should define your own equality functions rather than use the equality and inequality operators of the complex class.

Related Concepts

Related Tasks