cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
How to calculate XOR on a given interval
How to calculate XOR on a given interval of numbers
Sep 26, 2021 at 3:15pm UTC
Qsh222
(6)
For example, you're given the interval 5 15 17 90. How to calculate the XOR of it?
Sep 26, 2021 at 3:26pm UTC
helios
(17574)
Set a variable to zero, and succesively XOR by each element then store back into it.
Sep 26, 2021 at 4:10pm UTC
jonnin
(11437)
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 UTC
Sep 26, 2021 at 4:21pm UTC
JLBorges
(13770)
> 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 UTC
helios
(17574)
OP probably meant "sequence", not "interval".
Topic archived. No new replies allowed.