5 ms·
Could someone explain what "result |= x ^ y" does? Better yet, can someone point me to a search engine that lets me search for symbols? http://www.google.com/s
by RegEx 15y ago
Could someone explain what "result |= x ^ y" does? Better yet, can someone point me to a search engine that lets me search for symbols?
http://www.google.com/search?q=python+|%3D http://www.google.com/search?q=python+|%3D
- matthavener 15y ago| is bitwise OR ^ is bitwise XOR so, "result |= x ^ y" will change result to true if x and y are different. since its bitwise, the bits that are different between x and y will be set in result
- reemrevnivek 15y agoMore precisely, "result |= x ^ y" will change result to be nonzero, not "true". For example, if x = 0b0101 and y = 0b0011, x ^ y = 0b0110. If result was previously 0b0011 from a previous test, then after "result |= 0b0110" result will be 0b0111. Of course, in many programming languages (including Java and Python), a value of zero is interpreted as false and anything else is true.
- injekt 15y agoTry using words instead, http://www.google.com/search?q=python+pipe+equals http://www.google.com/search?q=python+pipe+equals
- Confusion 15y agoresult |= x ^ y means result = result | (x ^ y) means result = result 'bitwise-or' (x 'bitwise-xor' y)