XOR from only OR and AND
问题 How do you do the XOR bitwise operation if you only have available the AND and the OR operations? 回答1: Creating my own scripting language - ChrisScript - you just need something like: #!/bin/chrish bit XOR (bit A, bit B) { bit notA; bit notB; IF (A == 0) notA = 1 ELSE notA = 0; IF (B == 0) notB = 1 ELSE notB = 0; F = ((A && notB) || (notA && B)); RETURN F; } Even without NOT, it can be emulated like this. But this is the best solution you're going to get without having some form of inverter.