BitwiseAND

Description

Allows you to compare the binary values of two variables with unsigned long datatypes.

Syntax

BitwiseAND ( val1, val2)

Argument

Description

val1

Unsigned long for the first operand you want to compare

val2

Unsigned long for the second operand you want to compare

Returns

UnsignedLong. Returns the matching bit or bits, or returns 0 when there is no match. If one of the arguments is null, BitwiseAND returns null.

Usage

The bitwise AND operator compares each bit of its first operand to the corresponding bit of its second operand.

Examples

Example 1

This example compares the binary values of the ll_a1 and ll_a2 variables that are set to 10 (hexadecimal value 0x0A) and 12 (hexadecimal value 0x0C), respectively:

ULong ll_a1, ll_a2, ll_result

ll_a1 = Long ("0x0A")

ll_a2 = Long ("0x0C")

ll_result = BitwiseAND(ll_a1, ll_a2)

messagebox ("Result", string (ll_result, "hex4"))

In the above example, the first hexadecimal value has binary bits in the second and fourth positions. If you compare this to the second hexadecimal value, which has binary bits in the third and fourth positions, the only match is in the fourth position, which is equivalent to a decimal value of 8, or a four-place hexadecimal value of 0008.

See also