Math.And

Top  Previous  Next

 

Syntax

function Math.And(Op1, Op2: integer): integer

 

Alternative Names

ibec_And

 

Description

Performs a bitwise logical AND operation.

 

Both Op1 and Op2 hold a value, then Return Value is a bitwise logical AND operation for each bit in the input values.

 

Bitwise AND is performed as follows for bit values p & q:

 

p

q

AND

0

0

0

0

1

0

1

0

1

1

1

1

 

See Also

Math.And
Math.Or
Math.Xor

 

Example

execute UDSBlock 

as

begin

  Op1 = 3; /* 11 in binary */

  Op2 = 1; /* 01 in binary */

  Res = Math.And(Op1, Op2); /* Result 01 in binary, 1 in decimal */

  GUI.ShowMessage('Result 01 (bin) = 1 (dec): ' || Res);

  

  Op1 = 2; /* 10 in binary */

  Op2 = 1; /* 01 in binary */

  Res = Math.Or(Op1, Op2); /* Result 11 in binary, 3 in decimal */

  GUI.ShowMessage('Result 11 (bin) = 3 (dec): ' || Res);

  

  Op1 = 2; /* 10 in binary */

  Op2 = 3; /* 11 in binary */

  Res = Math.Xor(Op1, Op2); /* Result 01 in binary, 1 in decimal */

  GUI.ShowMessage('Result 01 (bin) = 1 (dec): ' || Res);

end