Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does XORing for 2 decimal numbers mean? [closed]

Tags:

xor

I know that XORing 2 decimal numbers mean that, they binary representations are XORed.
But what does it mean non-mathematical sense ?
What significance does it have?

like image 282
user2713461 Avatar asked Dec 09 '14 18:12

user2713461


2 Answers

If you XOR the result with one of the original numbers, you get the other original number.

a ^ b = X
X ^ a = b
X ^ b = a

This is used commonly in cryptography and hashing algorithms.

like image 161
Freddie Chopin Avatar answered Oct 07 '22 22:10

Freddie Chopin


In simple words, the XOR of two decimal means, first converting the two decimals to binary and then performing the bit-wise XOR and then again converting the result to decimal.

Let's take an example,

Suppose we wanna find out what does 3^7 results? (where ^ is symbolising XOR operation)

Step 1 : Converting the numbers from decimal to binary

3 => 0011 and 7 => 0111

Step 2 : Taking the bit-wise XOR of the two binary numbers

  3  : 0011
  7  : 0111
 3^7 : 0100

(hint : 1^0 = 1 and 1^1 = 0^0 = 0)

Step 3 : Convert the answer to decimal

0100 => 4

Hence, the 3^7 = 4

Click here for more details.

like image 20
Deepam Gupta Avatar answered Oct 07 '22 20:10

Deepam Gupta