VMS Help
FORTRAN, Data, Expressions
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
An expression represents a single value. An expression can consist
of a single constant, variable, record element, array element, or
function reference; or combinations of these data items plus
certain other elements, called operators. Operators specify
computations to be performed on the values of the data items and a
single result is obtained.
Expressions are classified as arithmetic, character, relational, or
logical. Arithmetic expressions produce numeric values; character
expressions produce character values; and relational and logical
expressions produce logical values.
The data components of an expression must be compatible and must be
joined by compatible operators. Expressions are evaluated one
operator at a time according to the rules of precedence. The
ranking assigned to each data type is as follows:
Data Type Ranking
--------- -------
BYTE, LOGICAL*1, INTEGER*1 1 (lowest)
LOGICAL*2 2
LOGICAL*4 3
INTEGER*2 4
INTEGER*4 5
REAL*4 (REAL) 6
REAL*8 (DOUBLE PRECISION) 7
REAL*16 8
COMPLEX*8 (COMPLEX) 9
COMPLEX*16 (DOUBLE COMPLEX) 10 (highest)
Arithmetic expressions contain numeric data such as variables,
record elements, array elements, constants, function references,
and arithmetic expressions enclosed in parentheses. The expression
evaluates to a numeric value. The numeric operators are as
follows:
OPERATOR RANK DESCRIPTION
** 1 exponentiation (evaluated
right to left)
* 2 multiplication
/ 2 division
+ 3 addition
- 3 subtraction
You can use parentheses to force an order of evaluation.
Character expressions consist of character elements and character
operators. Evaluation of a character expression yields a single
value of character data type. A character element can be a
constant, variable, record element, array element, substring,
expression (optionally enclosed in parentheses), or a function
reference.
A character expression has the form:
character element[//character element]...
The concatenation operator (//) is the only character operator.
Concatenation is from left to right.
Logical expressions can contain logical and integer data such as
variables, record elements, array elements, constants, function
references, expressions enclosed in parentheses, and relational
expressions. The expression evaluates to a logical value using the
following operators:
OPERATOR PRECEDENCE
** First (Highest)
*,/ Second
+,-,// Third
Relational
Operators Fourth
.NOT. Fifth
.AND. Sixth
.OR. Seventh
.XOR. Eighth (Lowest)
.NEQV. Eighth
.EQV. Eighth
Relational expressions consist of either two arithmetic or two
character expressions separated by relational operators. The
expression is reduced to a logical value (true or false).
OPERATOR DESCRIPTION
.LT. Less than
.LE. Less than or equal to
.EQ. Equal to
.NE. Not equal to
.GT. Greater than
.GE. Greater than or equal to
Expressions of COMPLEX data type can use only .EQ. and .NE.
operators.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.