Hi! I am actually a PHP programmer Not a Maths Guy .
I was making a strong Xor encryption function. While doing that I wondered on this three numbers (10, 20, 30).Code:10 Xor 20 Xor 30 Xor S results Se.g. Wherever I put the S it results to S if the numbers are 10, 20, 30 Why its happening ?? Please help .Code:10 Xor S Xor 30 Xor 20 results S
Are you sure that 10: 1010 rather than 00001010?
and what about S?
(binary add without carry, also I have set them to a field width of 8 bits which realy does not make a lot of difference but may well be what the machine is doing)
Well I've simplified my Problem
andCode:10 Xor 20 Xor 30 is 0
AndCode:0 Xor S results S
10 Xor 20 = 30
10Xor 30 = 20
20 Xor 30 = 10
In a Cyclick order.
And I think If an Expression with Xor results 0 it means
Say a Xor b Xor c Xor d Xor e ........ = 0
b Xor c Xor d Xor e ........ = a
a Xor c Xor d Xor e ........ = b
e.g. Xor of all other element must be equal to the 1(or more Xored) rest element(s)
e.g. if its a Xor b Xor c Xor d = 0
a Xor c = b Xor d
a Xor d = b Xor d
and so on.
bit position and zero otherwise. There are an even number of bits set in each
position in 10, 20 and 30, so when xor-ed with any bit pattern in any order
the result has the same bit pattern as the extra bit pattern.
Alternate explanation is that xor is both associative and comultative so the
order of xor-s does not matter, so as 10 xor 20 xor 30 = 0 the result follows.