HP Fortran Programmer's Reference (September 2007)

Expressions and assignment
Expressions
Chapter 488
Operands of logical and integer types may be combined with the arithmetic operators. The
logical variable is treated as an integer of equivalent size, and the result of the operation
is an integer value. When different lengths of operands are involved, the shorter is
considered extended as a signed integer. The following is an example:
LOGICAL(1) :: boolean1 = -4
LOGICAL(4) :: boolean4 = 2**16 + 27
INTEGER(1) :: flag1
INTEGER(4) :: flag4
flag4 = boolean4 - boolean1 !set flag4 to 2**16 + 31
! a relational operator with a logical operand
IF (boolean4 > 65536) THEN
flag1 = -(boolean4/65536) !set flag1 to -1
ENDIF
Relational operators
The relational operators are .EQ., .NE., .GT., .GE., .LT., .LE., ==, /=, >, >=, <, and <=. All
relational operators are binary. The letter forms of the relational operators have the same
meaning as the symbol forms. Thus, .EQ. is a synonym for ==, .NE. is a synonym for /=, and
so on.
If the operands in a relational operation are numerical expressions with different type or kind
type parameters, the operands are converted to the type and kind type parameters that the
sum of the operands would have and are then compared; see “Arithmetic operators” on
page 86 for information about the result of mixed arithmetic expressions.
If the operands are character expressions, the shorter operand is blank-padded to the length
of the other prior to the comparison. The comparison starts at the first character and proceeds
until a character differs or equality is confirmed. See Appendix C for the collating sequence.
Concatenation operator
The concatenation operator is //. It is binary.
In a concatenation operation, each operand of the concatenation operator must be of type
character and have the same kind type parameter. The character length parameter of the
result is the sum of the character length parameters of the operands.
Logical operators
The logical operator are .AND., .OR., .EQV., .NEQV., .XOR., and .NOT.. The .NOT. operator is
unary; the others are binary. The .XOR. is an HP extension having the same meaning as the
.NEQV. operator.