BitwiseOR

Description

Allows you to combine the bits from two binary numbers in an inclusive OR operation.

Syntax

BitwiseOR ( val1, val2)

Argument

Description

val1

Unsigned long for the first binary number that you want to use in an inclusive OR operation

val2

Unsigned long for the second binary number that you want to use in an inclusive OR operation

Returns

UnsignedLong. Returns the result of a bitwise OR operation. If one of its arguments is null, BitwiseOR returns null.

Usage

The bitwise “inclusive” OR operator compares each bit of its first operand to the corresponding bit of its second operand. If either or both operands has a bit value of 1 at a particular position, the result bit is set to 1 at that position. Otherwise, the corresponding result bit is set to 0.

Examples

Example 1

This example compares the values of the bits in the firstValue and secondValue variables:

UnsignedLong ll_result

ll_result = BitwiseOR(firstValue, secondValue)

In this example, if firstValue is 10, it has positive bits in the second and fourth positions. If secondValue is 12, it has positive bits in the third and fourth positions. When you combine the binary values of 10 and 12 in a bitwise inclusive OR operation, the result is 14, with positive bits in the second, third, and fourth positions.

See also