Positron Compiler Documentation

Logical and '&'

Positron16 · Revision 1.1.3.5 · PDF page 83

Assignment Variable = Variable & Variable

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

0 and 0 = 0 0 and 1 = 0 1 and 0 = 0 1 and 1 = 1

The result returned by & will contain 1s in only those bit positions in which both input values contain 1s.

Variables may be constants, variables or expressions. Assignment Variable can be any valid variable type.

Device = 24FJ64GA002           ' Select the device to compile for
Declare Xtal = 16      ' Tell the compiler the device will be operating at 16MHz

Declare Hserial1_Baud = 9600
Declare Hrsout1_Pin = PORTB.14

Dim MyByte1 as Byte = %00001111
Dim MyByte2 as Byte = %10101101
Dim MyResult as Byte

PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX

MyResult = MyByte1 & MyByte2
HrsoutLn Bin MyResult                   ' Display and result (%00001101)

or

HrsoutLn Bin (%00001111 & %10101101)   ' Display and result (%00001101)

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

View original PDF page 83Open page in PDFOriginal PDF page 83