Operator | Meaning |
---|---|
.eq. | equal to |
.ne. | not equal to |
.lt. | less than |
.le. | less than or equal to |
.gt. | greater than |
.ge. | greater than or equal to |
These logical operators are used to compare two values of the same type.
Example
Given that the REAL variable speed1 has the value 83.4 and the REAL variable speed2 has the value 96.3 Table 2 shows possible expressions and their values.
Expression | Value |
---|---|
(speed1 .gt. 50.0) | .true. |
(speed1 .ge. speed2) | .false. |
(speed1 .ne. speed2) | .true. |
Operator | Meaning |
---|---|
.not. | Changes the value of the expression to the opposite value |
.and. | True only if both logical expressions are true |
.or. | True if either logical expression is true |
.xor. | True if only one expression is true (exclusive or) |
.eqv. | True if the expressions have the same truth value |
.neqv. | True if the expressions do not have the same truth value |
Example
The order of precedence for operators from highest to lowest is
Within the same level of priority, evaluation will proceed left to right.
Enter, compile, and execute the program. Input a value for the variable temp that
2. In the following exercise, given the following type and assignment statements, determine the value of the expressions (.true. or .false.) if year = 1974, mass = 2.345, start = 5, weight = 234.23, and pi = 3.14. (Only one of the expressions is false.)
4. Complete the following truth table.
A | B | .not.a | a .and. b | a .or. b | a .xor. b | a .eqv. b | a .neqv. b |
---|---|---|---|---|---|---|---|
T | T | ||||||
T | F | ||||||
F | T | ||||||
F | F |
5. Given the following declarations and initializations, what is the value of each logical expression?