Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an XOR sum?

I am not sure of the precise definition of this term.

I know that a bitwise XOR operation is going bit by bit and taking the XOR of corresponding bits position wise. Is this result termed the 'XOR sum'? If not, what is an XOR sum, and how do you use XOR to implement this addition?

like image 746
user2517777 Avatar asked Jun 24 '13 20:06

user2517777


People also ask

Is XOR like addition?

We can (and will) interchangeably consider these values as being 1 or 0 respectively, and that is why XOR is typically represented by the symbol ⊕: it is equivalent to the addition operation on the integers modulo 2 (i.e. we wrap around so that 1 + 1 = 0) 1 [ SurreyUni ].

What does XOR mean in math?

XOR is a binary operation, it stands for "exclusive or", that is to say the resulting bit evaluates to one if only exactly one of the bits is set.

What is meant by XOR operation?

XOR is a bitwise operator, and it stands for "exclusive or." It performs logical operation. If input bits are the same, then the output will be false(0) else true(1).

What is XOR example?

Examples: 1 XOR 1 = 0. 1 XOR 0 = 1. 0 XOR 1 = 1.


1 Answers

In a bit wise XOR operation:

a   b   a^b ----------- 0   0    0 0   1    1 1   0    1 1   1    0  

XOR sum refers to successive XOR operations on integers.
Suppose you have numbers from 1 to N and you have to find their XOR sum then for N = 6, XOR sum will be 1^2^3^4^5^6 = 7.

1 = 001,  2 = 010,   3 = 011,   4 = 100,   5 = 101,   6 = 110     1^2          = 1^2  = 001^010 = 011 = 3   (1^2)^3       = 3^3  = 011^011 = 000 = 0 (1^2^3)^4     = 0^4  = 000^100 = 100 = 4 (1^2^3^4)^5   = 4^5  = 100^101 = 001 = 1 (1^2^3^4^5)^6 = 1^6  = 001^110 = 111 = 7 --> XOR sum 

Hope this will help.

like image 52
haccks Avatar answered Oct 12 '22 20:10

haccks