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.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net