Complement '~'
Positron8 · Revision 4.0.6.5 · PDF page 92
Syntax
Assignment Variable = ~Variable
Overview
The Complement operator inverts the bits of a value. Each bit that contains a 1 is changed to 0 and each bit containing 0 is changed to 1. This process is also known as a "bitwise not".
Parameter
Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
Example
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 Wordout as Word
Dim Wordin as Word
Wordin = 0b1111000011110000
Wordout = ~Wordin ' Complement the value held in Wordin
HRsoutLn Bin16 Wordout ' Display the result on a serial terminal
Note.
Complementing can be carried out with all variable types except Floats. Attempting to complement a floating point variable will produce a syntax error.
