Positron Compiler Documentation

Logical or '|'

Positron8 · Revision 4.0.6.5 · PDF page 88

Assignment Variable = Variable | Variable

The Or operator returns the bitwise Or of two values. Each bit of the values is subject to the following logic: -

0 or 0 = 0 0 or 1 = 1 1 or 0 = 1 1 or 1 = 1

The result returned by | will contain 1s in any bit positions in which one or the other (or both) input values contain 1s.

Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.

Device = 18F26K40                      ' Select the device to compile for
Declare Xtal = 16  ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600             ' Set the Baud rate for HRsoutLn

Dim bMyVar1 as Byte
Dim bMyVar2 as Byte
Dim bMyResult as Byte

bMyVar1 = 0b00001111
bMyVar2 = 0b10101001
bMyResult = bMyVar1 | bMyVar2
HRsoutLn Bin bMyResult                   ' Display the OR binary result: 10101111
Device = 18F26K40                      ' Select the device to compile for
Declare Xtal = 16  ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600             ' Set the Baud rate for HRsoutLn

HRsoutLn Bin (0b00001111 | 0b10101001)  ' Display the OR binary result: 10101111

Bitwise operations are not permissible with floating point constants or variables.

View original PDF page 88Open page in PDFOriginal PDF page 88