     Next: Handles Up: Data Types Previous: Pointers   Contents   Index

## Complex

Support for complex numbers is provided via the complex data type. The basic math operators and functions accept complex numbers, possibly intermixed with scalar values, and will produce a complex result when given a complex operand when appropriate. Generally, a complex number can be passed to a function expecting a real number, and the real part of the complex number will be used. Similarly, a scalar passed to a function expecting a complex number will be accepted as a complex value with zero imaginary part.

Presently, functions will not produce a complex result unless passed a complex argument. For example, the sqrt function, if passed a negative scalar, will return a scalar zero. If passed a complex number with negative real part and zero imaginary part, the return will be the complex square root value as one would expect.

Complex numbers can be created with the cmplx initializer function, which takes as arguments two scalar values that initialize the real and imaginary part. There are special functions that return as scalars the real and imaginary values, magnitude, and phase of a complex operand. The Print function and similar will print a complex value as a comma-separated pair of numbers enclosed in parentheses.     Next: Handles Up: Data Types Previous: Pointers   Contents   Index
Stephen R. Whiteley 2022-05-28