OR operator

Purpose

The OR operator works as both a logical and a bitwise arithmetic operator.

Syntax

p OR q

Remarks

Using OR as a logical operator

OR returns TRUE (non-zero) if and only if either or both of its operands is TRUE.  Here is OR's truth table:

Truth table

x

y

x OR y

T

T

T

T

F

T

F

T

T

F

F

F

 

Using OR as a bitwise arithmetic operator

An OR mask sets selected bits of an integer-class value without affecting the other bits.  To set the most significant 2 bits in &H9700, use OR with a mask of &HC000; that is, the mask contains all 0s, except for the bit positions you wish to force to 1:

See also

Arithmetic OperatorsAND, EQV, IMP, ISFALSEISTRUENOT, XOR