How to calculate XOR on a given interval of numbers

For example, you're given the interval 5 15 17 90. How to calculate the XOR of it?
Set a variable to zero, and succesively XOR by each element then store back into it.
the operator ^ is xor.
eg a = b^c;

what do you really want? xor by a sequence is going to flop around and generate nonsense ..
1 ^ 2 is 3, which ^ 3 again is zero, which xored with 4 is 4... I see no meaning to this.
Last edited on
> xor by a sequence is going to flop around

This clever algorithm exploits that property to compute the XOR of numbers in the closed interval [a,b]
https://stackoverflow.com/q/10670379
OP probably meant "sequence", not "interval".
Topic archived. No new replies allowed.