Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1335

# Is Xor an operator or a function?

I learned in school Xor as:

True True = False
True False = True
False True = True
False False = False

I thought of the Xor operator as a operator but found it acts like a function.

I use a Xor b and I get c
Then:
a Xor c = b
b Xor a = c
b Xor c = a
c Xor a = b
c Xor b = a

Example:
15 Xor 100 = 107
15 Xor 107 = 100
100 Xor 15 = 107
100 Xor 107 = 15
107 Xor 15 = 100
107 Xor 100 = 15

What is the math formula?
0
rcherne1
1 Solution

Commented:
XOR is an operator

If you use numbers with XOR in VB, XOR compares every bit of each number and returns another number.
Use the windows cientific calculator and you'll get the same result.

Example:

15 XOR 100 = 107

Decimal       Binary (bits)
15        =    00001111
100        =   01100100

So VB compares each bit of each number:

00001111
xor   01100100
-----------
01101011

And if you convert 01101011 to decimal then you get 107
0

Author Commented:
Thanks rettiseert I was racking my brain trying to figure this out!
0

## Featured Post

Tackle projects and never again get stuck behind a technical roadblock.