AND

Returns the bitwise AND of two or more inputs.

Signature

     ┌─────────┐
IN1 ─┤         │
IN2 ─┤   AND   ├─ OUT
IN3 ─┤         │
     └─────────┘
FUNCTION AND : ANY_BIT
  VAR_INPUT
    IN1 : ANY_BIT;
    IN2 : ANY_BIT;
    (* ... additional inputs ... *)
  END_VAR
END_FUNCTION

The return type matches the input type. AND accepts BOOL, BYTE, WORD, DWORD, LWORD. All inputs must share the same type.

Inputs

Name

Type

Description

IN1

ANY_BIT

The first operand.

IN2

ANY_BIT

The second operand.

Outputs

Name

Type

Description

Return value

ANY_BIT

Each bit set in every input. Same type as the inputs.

Description

On BOOL inputs, returns TRUE only when every input is TRUE. On BYTE, WORD, DWORD and LWORD inputs, each bit of the result is set only when the same bit is set in every input. AND(a, b) is the functional form of the AND operator: a AND b. Both forms are equivalent, and AND(a, b, c) is a AND b AND c.

Example

result := AND(WORD#16#F0F0, WORD#16#FF00);   (* result = 16#F000 *)
result := WORD#16#F0F0 AND WORD#16#FF00;     (* operator form *)
result := AND(WORD#16#F0F0, WORD#16#FF00, WORD#16#0FF0);   (* result = 16#0000 *)

See Also

References