Skip to content

IAND Operator

See Also: AND operator, IOR operator, Hi function, Low function

Purpose

To return the bitwise AND of two integer values.

Syntax

( {value1} IAND {value2} )

where {value1} and {value2} may be either expressions, variables, or constants.

What It Does

When two values are connected with an encompassing expression by IAND, the encompassing expression evaluates as the value of a binary number derived from the other two values as 1 in positions where both values are 1, and 0 in positions where either value is 0.

Example

move (iMode IAND iForm) to iForm

In this example, 1s in the binary form of the value of iForm are changed to 0s, except for those positions where the binary form of the value of iMode has 1s.

Multiple IANDs may be used to link more than two values into a single expression that evaluates as the bitwise AND of all the values in the expression:

Example

while (iPass1 IAND iPass2 IAND iPass3)
// some code in loop
loop

In this example, the block of commands controlled by while is executed until no position in the binary form of the values of all three variables iPass1, iPass2, and iPass3 contains a 1.

Notes

  • There is no symbolic substitute for the word IAND.

  • When IANDs, IORs, and other arithmetic operators are intermingled in a single expression without grouping parentheses, evaluation proceeds from left to right with each operator connecting the next expression with the result of all previous (left-lying) ones.

(1 IAND 2 IOR 3 IAND 4)

would evaluate as 0, while

(1 IOR 2 IAND 3 IOR 4)

would evaluate as 7.