2.2.1.3 Complex Constants

A complex constant is a pair of real or integer constants. The two constants are separated by a comma and enclosed in parentheses. The first constant represents the real part of that number; the second constant represents the imaginary part.

Compaq Fortran 77 supports COMPLEX*8 and COMPLEX*16 complex constants.

COMPLEX (COMPLEX*8) Constants

A COMPLEX constant is a pair of integer or REAL constants that represent a complex number. It takes the following form:

(c,c)
c
Is an integer or REAL constant.

Rules and Behavior

A COMPLEX constant occupies eight bytes of memory and is interpreted as a complex number.

The parentheses and comma are required parts of the constant.

Syntax rules for REAL constants apply to REAL constants used in COMPLEX constants. (See Section 2.2.1.2 for the rules on forming REAL constants.)

Examples

The following examples show valid and invalid COMPLEX constants:

Valid   
(1.7039,-1.70391)    
(+12739E3,0.)    
(1,2)    
Invalid  Explanation 
(1.23,)   Missing second REAL constant 
(1.0, 2H12)   Hollerith constant not allowed 

For More Information:


DOUBLE COMPLEX (COMPLEX*16) Constants

A DOUBLE COMPLEX constant is a pair of constants that represents a complex number. One constant must be DOUBLE PRECISION; the other constant must be an integer, REAL, or DOUBLE PRECISION. The two constants are separated by a comma and enclosed in parentheses; the first constant represents the real part of the complex number, the second the imaginary part.

A DOUBLE COMPLEX constant takes the following form:

(c,c)
c
Is an integer, a REAL, or a DOUBLE PRECISION constant. (At least one of the pair must be a DOUBLE PRECISION constant.)

Rules and Behavior

A DOUBLE COMPLEX constant occupies 16 bytes of memory and is interpreted as a complex number.

The parentheses and the comma are required parts of the constant.

Syntax rules for DOUBLE PRECISION constants also apply to the DOUBLE PRECISION portion of DOUBLE COMPLEX constants. (See Section 2.2.1.2 for the rules on forming DOUBLE PRECISION constants.)

The DOUBLE PRECISION constant in a DOUBLE COMPLEX constant can have the following implementations:

Examples

The following examples show valid and invalid DOUBLE COMPLEX constants:

Valid                
(1.7039,-1.7039D0)  
(+12739D3,0.D0)    
Invalid               Explanation
(1.23D0,)   Second constant missing 
(1D1,2H12)   Hollerith constants not allowed 
(1,1.2)   One constant must be DOUBLE PRECISION 
(1.0D300,-1.0D300) Both constants out of range for D_floating implementation of DOUBLE PRECISION. They are valid for the OpenVMS G_floating and Alpha T_floating implementation of DOUBLE PRECISION. 

For More Information:


Previous Page Next Page Table of Contents