BIN_AND()

BIN_AND(V1,V2)

RETURNS THE BINARY LOGICAL "AND" BETWEEN THE VALUES V1 AND V2

  • Type: Function
  • Parameters: 2
  • Group: Mathematics

ACTION

The function BIN_AND(V1,V2) returns the value of the binary logical "AND" between V1 and V2.

V1 and V2 are data or variables which can be real or integer.

If a value is real, it is rounded to the nearest integer before the logical operation.

The logical operation is made bit-by-bit:

1 AND 1 = 1

1 AND 0 = 0

0 AND 1 = 0

0 AND 0 = 0

Applications:

1 - to force a bit to 0

If the variable V1 has a value between 0 and 255, after V1=BIN_AND(V1,254), V1 has its last significant bit forced to 0, the other bits remain unchanged.

2 - to know a determined bit in an integer

BIN_AND(V1,1) gives the value of the last significant bit of V1.

SYNTAX: Result=BIN_AND(V1,V2)

  • V1 = integer or real data.
  • V2 = integer or real data.

USE

  • The function BIN_AND() is used to force a bit to 0 or to know a bit in an integer.

ERROR

  • If V1 or V2 are not correct expressions.

EXAMPLE

print bin_and(3,5)

print "Result = 1"

SEE ALSO

BIN_OR()

BIN_XOR()