Arithmetic operators
The basic arithmetic operators
+,
(unary and binary),
/,
and
,
the assignment operators
=,
+=,
=,
=,
and
/=,
as well as the equality operators
==
and
!=,
can be used for complex numbers.
The operators have their conventional precedences.
For example:
a=b*c+d
for complex variables
a,
b,
c,
and
d
is equivalent to
a=(bc)+d.
There are no operators for exponentiation and conjugation;
instead the functions
pow()
and
conj()
are provided.
The operators
+=,
=,
=,
and
/=
do not produce a value that can be used in an expression; thus the
following examples will cause compile time errors:
complex a, b;
// ...
if ( (a+=2)==0 ) { //error
// ...
}
b = a *= b; //error
Next topic:
Mixed mode arithmetic
Previous topic:
Cartesian and polar coordinates
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004