12/5/13

XOR operations.

XOR stands for 'Exclusive Or', or 'Exclusive Alternative'.

It's used often in Information Technology Sector.

It can be used as Logical Operator or (Bitwise) Arithmetic Operator.

As Logical Operator, it evaluates to truth when and only when logical operands (input data) are different.

For example:

TRUE XOR TRUE = FALSE
TRUE XOR FALSE = TRUE
FALSE XOR TRUE = TRUE
FALSE XOR FALSE = FALSE

As Arithmetic Operator, it 'sums' (more appropriately: XORs) two bits (zeros or ones), resulting in 0 or 1, as follows:

1 XOR 1 = 0
1 XOR 0 = 1
0 XOR 1 = 1
0 XOR 0 = 0

More than one bit can be used, each is evaluated separately, for example:

11 XOR 11 = 00
10 XOR 11 = 01
01 XOR 11 = 10
00 XOR 11 = 11

etc..

Please note that XOR operation is reversible. That is, XORing operand 1 twice with the operand 2 will yeld operand 1 in the result.

For example:

111 XOR 010 XOR 010 = 111, because:

111 XOR 010 = 101

and

101 XOR 010 = 111.

No comments:

Post a Comment