How to calculate XOR on a given interval of numbers

Sep 26, 2021 at 3:15pm
For example, you're given the interval 5 15 17 90. How to calculate the XOR of it?
Sep 26, 2021 at 3:26pm
Set a variable to zero, and succesively XOR by each element then store back into it.
Sep 26, 2021 at 4:10pm
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 Sep 26, 2021 at 4:13pm
Sep 26, 2021 at 4:21pm
> 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
Sep 26, 2021 at 4:56pm
OP probably meant "sequence", not "interval".
Topic archived. No new replies allowed.