As background bitwise operators operate at the "bit" level of programming. Bits are the smallest unit of storage a computing machine is capable of. All machine instructions, code, data, video graphics, keyboard characters, everything in a computer is composed of groups of bits arranged in various ways. A bit is actually so small that it can only hold two distinct values a 0 or a 1. Amazingly, by putting bits together in groups you can represent virtually any conceivable size number. This characteristic of being able to hold only 2 values (0 or 1) is called "binary" representation.
To understand bitwise operators you need to understand that when a computer stores data or code it has to put them in computer memory somewhere. That computer memory is made up of things called "gates" and storage units called "flip-flops" that can be wired together in certain ways to make bigger units of storage. When a computer retrieves that information it retrieves them in bits lumped together into things called "nybbles"(4bits in a chunk), "bytes"(8bits in a chunk), "words"(16bits in a chunk), "double-words"(32bits) and even larger units. Regardless of how many bits have been put together to make larger units of information, the bitwise operators operate on only 1 bit at a time. But they can also be combined in various ways to make "nybble operators" "byte operators", "word operators" etc.
The easiest way to describe how bitwise operators work is through the use of what are called "bit tables" each bit table describes an operation that can be done on a single bit using another bit as a pattern. Although there may be some disagreement between computer professionals as to how many absolutely rock bottom simple bit operations there truly are the consensus is that there are only 3 that are what are called "primitive" bitwise operators -- the AND(&) operator, the OR(|) operator, and the NOT(~) operator. All other bitwise operators can be constructed using combinations of just those 3 alone.
Bitwise operators actually need 2 bits to work properly -- one for the item to be managed or altered in some way and one for the pattern that the operator will use to tell it how to change the first bit. The Not operator is the only exception to the rule of using 2 bits for the operation. I know, it seems confusing but an example may help.
for example the bit table for an "and" bitwise operator is..
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1For the or operator the table is slightly different
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1For the not operator the table is much different
~0 = 1
~1 = 0At this point we get into the horrible world of "boolean" or "bitwise algebra" As complicated as that may sound, all that means is that we use letters like A and B for the bit groups we intend to use instead of the numbers. That substitution helps to clarify some more advanced rules for the way these bit groups are combined and manipulated later on. So an AND operator can be redescribed as C = A & B where A is some grouping of bits and B is the pattern to be used for tweaking A. Likewise the OR operator can be descibed as C = A | B. And the NOT operator would become B = ~A.
You can find lots more information on this stuff at http://en.wikipedia....twise_operation
and yes it can get a little overwhelming if you try to digest it all at once.