June 23, 2009
Bitwise Operations: Part 1
What
First lets begin by establishing the meaning of bitwise;
Bitwise: Being an operation that treats a value as a series of bits rather than a numerical quantity.
And what this means is that we will be dealing with bits in the binary numeral system, so in essence we will be dealing with sequences of zeroes(0) and ones(1).
Why
Bitwise Operations work at the binary level and can have memory saving consequences when used properly. They also make storing a vast number of boolean value in one number possible, which can lead to a better designed system.
Signs
Bitwise Operations use their own set of operators which include the following;
& BITWISE AND | BITWISE OR ^ BITWISE xOR ~ BITWISE NOT >> BITWISE SHIFT RIGHT << BITWISE SHIFT LEFT
*Note, these operators night be different depending on language specifications, the ones shown here are primarily taken from PHP, as that we be the language used to provide an example in later articles.