Bitwise inversion ( ~ ) is a unary operator (meaning that it acts on a single operand) that simply flips the bits of a primitive numeric value. However, it can not be applied to booleans.
To "flip" a boolean value, use the unary "not" ( ! ), which can be applied only to booleans.
Bitwise operators "and" ( & ), "or" ( | ), and "exclusive or" ( ^ ) are binary operators (meaning that 2 operands are involved) that can be applied to either primitive numerics or booleans.
The short-circuiting versions of "and" and "or" ( && and || ) can be used only with booleans. [ December 06, 2005: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org