The ~ operator in C ++ (and other C-like languages ββsuch as C and Java) performs a bitwise NOT operation - all 1 bits in the operand are set to 0 and all 0 bits in the operand are 1. In other words, it adds to source number.
For example:
10101000 11101001 // Original (Binary for -22,295 in 16-bit two complement) 01010111 00010110 // ~Original (Binary for 22,294 in 16-bit two complement)
In your example, ch=~((ch^i)) performs bitwise NOT on the bitwise XOR ch and i , then assigns the result to ch .
The bitwise NOT operator has an interesting property, which when applied to numbers represented by two additions , changes the sign of the number and then subtracts one (as you can see in the above example).
You might want to familiarize yourself with the various operators of the C ++ language , since it is difficult to find operators in search engines. Even better, you can get a good C ++ book that tells you about C ++ statements.
In silico Oct 17 '10 at 5:18 2010-10-17 05:18
source share