This is an old version, view current version.

## 4.2 Complex constructors and accessors

### 4.2.1 Complex constructors

Variables and constants of type complex are constructed from zero, one, or two real numbers.

complex z1 = to_complex();        // z1 = 0.0 + 0.0i
real re = -2.9;
complex z2 = to_complex(re);      // z2 = -2.9 + 0.0i
real im = 1.3;
complex z3 = to_complex(re, im);  // z3 = -2.9 + 1.3i

complex to_complex()
Return complex number with real part 0.0 and imaginary part 0.0.
Available since 2.28

complex to_complex(real re)
Return complex number with real part re and imaginary part 0.0.
Available since 2.28

complex to_complex(real re, real im)
Return complex number with real part re and imaginary part im.
Available since 2.28

### 4.2.2 Complex accessors

Given a complex number, its real and imaginary parts can be extracted with the following functions.

real get_real(complex z)
Return the real part of the complex number z.
Available since 2.28

real get_imag(complex z)
Return the imaginary part of the complex number z.
Available since 2.28