COMPLEX (The GNU Fortran Compiler)

### 8.75 `COMPLEX` — Complex conversion function ¶

Synopsis:

  `RESULT = COMPLEX(X, Y)`

Description:

  `COMPLEX(X, Y)` returns a complex number where X is converted to the real component and Y is converted to the imaginary component.

Class:

  Elemental function

Arguments:

  X | The type may be `INTEGER` or `REAL`.
  Y | The type may be `INTEGER` or `REAL`.

Return value:

  If X and Y are both of `INTEGER` type, then the return value is of default `COMPLEX` type.

  If X and Y are of `REAL` type, or one is of `REAL` type and one is of `INTEGER` type, then the return value is of `COMPLEX` type with a kind equal to that of the `REAL` argument with the highest precision.

Example:

      program test_complex
          integer :: i = 42
          real :: x = 3.14
          print *, complex(i, x)
      end program test_complex

Standard:

  GNU extension

See also:

  `CMPLX` — Complex conversion function