BITWISE OPERATORS

Bitwise operators work much like logical operators do, except they compare values one bit at a time. The bitwise negation operator Not flips the bits in its operand from 1 to 0 and vice versa. The following shows an example:

    10110111
Not 01001000
 

The And operator places a 1 in a result bit if both of the operands have a 1 in that position. The following shows the results of combining two binary values by using the bitwise And operator:

    10101010
And 00110110
    00100010
 

The bitwise Or operator places a 1 bit in the result if either of its operands has a 1 in the corresponding position. The following shows an example:

    10101010
Or  00110110
    10111110
 

The bitwise Xor operator places a 1 bit in the result if exactly one of its operands, but not both, has a 1 in the corresponding position. The following shows an example:

    10101010
Xor 00110110
    10011100
 

There are no bitwise equivalents for the AndAlso and OrElse operators.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.179.161