print (3^4) How the above line executing. Kindly explain how it works?
3 = 0011 4 = 0100 Answer = 0111
3 decimal is 0011 binary 4 decimal is 0100 binary The XOR operator matches when one number has a 1 and the other has a zero in a position. So an XOR of 0011 and 0100 ==== gives 0111 which equals 7 in decimal.
Quote:How the above line executing. Kindly explain how it works?
print (3^4) # ^ anything at this place is an operator
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)