Next: Standard functions
Up: A short summary of
Previous: Data types, variables and
  Contents
The order in which expressions are evaluated
The following table gives a comparison between operators in Pascal and FORTRAN.
|
Pascal |
FORTRAN |
arithmetic operators |
|
|
- raising to a power |
|
** |
- multiplication |
* |
* |
- division |
/ |
/ |
- division of integers |
div, mod |
|
- addition |
+ |
+ |
- subtraction |
- |
- |
relational operators |
|
|
- smaller |
|
.lt. |
- greater or equal |
|
.le. |
- greater |
|
.gt. |
- greater or equal |
|
.ge. |
- equal |
= |
.eq. |
- not equal |
|
.ne. |
logical operators |
|
|
- not |
not |
.not. |
- and |
and |
.and. |
- or |
or |
.or. |
The order in which expressions are evaluated is as follows:
- **
- * and /
- + and -
- .lt., .le., .eq., .ne., .ge. and .gt.
- .not.
- .and.
- .or.
Within each level evaluation is performed from left to right.
The order of evaluation can be changed by using semicolons.
Example:
program order
implicit none
integer n, nmax
logical conv, result
conv = .true.
n = 5
nmax = 20
result = .not. conv .and. 2*n .lt. nmax
print *, 'result = ', result
end
If we execute the program above the expression is evaluated as follows:
- 2*n which gives r1 = 10
- r1 .lt. nmax, which gives r2 = .true.
- .not. conv, which gives r3 = .false.
- r3 .and. r2, which gives: .false.
The program will print: result = .false.
Next: Standard functions
Up: A short summary of
Previous: Data types, variables and
  Contents
Mathieu Pourquie
2001-02-28