As shown in the answer of dasblinkenlight, an xor can be emulated with nand, consisting of not and and. Analogously, the xor can be emulated with nor, consisting of not and or.
The expressions will look a bit complex in the end...
public class XorTest
{
public static void main(String[] args)
{
testNand();
testNor();
}
private static void testNand()
{
int a = 1234;
int b = 5678;
a = xorNand(a, b);
b = xorNand(b, a);
a = xorNand(a, b);
System.out.println(a);
System.out.println(b);
}
private static void testNor()
{
int a = 1234;
int b = 5678;
a = xorNor(a, b);
b = xorNor(b, a);
a = xorNor(a, b);
System.out.println(a);
System.out.println(b);
}
private static int xorNand(int a, int b)
{
return ~(~(a & ~(a & b)) & ~(b & ~(a & b)));
}
static int xorNor(int a, int b)
{
return ~(~(~(a | a) | ~(b | b)) | ~(a | b));
}
}
But I can't think of a way that does the same "only" with shifts or other "novel combinations of operators" - whatever this should mean, exactly...