The basic rules of XOR remains same for negative XOR operations as well, but how the operation really works in negative numbers could be useful for someone someday □. The following table could be useful in determining the sign of result. The MSB bit of result will denote the sign and the rest of the bits will denote the value of the final result. Similarly, for all negative numbers, we consider their representation in binary format using 2's complement (one of most commonly used) and do simple XOR on their binary representation. Since, the MSB becomes 0 after the XOR operation, so the resultant number we get is a positive number. The XOR operation will be done on all bits as usual. The 1 at the MSB ( Most Significant Bit ) denotes that the number represented by the binary representation is negative. denotes all 0s, the number of which depends on bits used for representation (32-bit, 64-bit, etc).
0 Comments
Leave a Reply. |