Purpose |
The EQV operator works as both a logical and a bitwise arithmetic operator. | ||||||||||||||||||
Syntax |
p EQV q | ||||||||||||||||||
Remarks |
Using EQV as a logical operator EQV returns TRUE (non-zero) if at least one bit in one operand contains the same value as the identical bit position in the other operand. Further, EQV will return zero if and only if there are no matching bit values between the two operands. This can occur when one operand is equal to the bitwise NOT value of the other operand. For example: IF x EQV y = 0 THEN statement …is equivalent to: IF x = NOT y THEN statement The EQV operator can be used for comparing signed and unsigned values of the same bit size, such as Long-integer and Double-word. This use of EQV is similar to using the BITS functions; however, care must be exercised to test the return value of EQV correctly, since EQV will return an unsigned value with all bits set only if the bit patterns of the two operands are an exact match. The EQV truth table looks like this:
Using EQV as a bitwise arithmetic operator The EQV operator is seldom used as a bitwise arithmetic operator, but here is an example: | ||||||||||||||||||
See also |
Arithmetic Operators, AND, IMP, ISFALSE, ISTRUE, NOT, OR, XOR | ||||||||||||||||||
Example |
IF (Var1& EQV Var2???) = BITS???(-1&) THEN ... IF (Val1% EQV Var2??) = &H0FFFF?? THEN ... IF -1& EQV BITS???(-1&) = &H0FFFFFFFF THEN ... IF -1% EQV BITS??(-1%) = &H0FFFF THEN ... |