Bitwise xor: ^, xor
The main area of application of the bitwise exclusive OR is encryption, because it has such a characteristic that reuse the same mask on result and we get back the original input, so the role of masks can be seen as key. it works as follows: if the bits have the same value so the result is 0, and when the bits value is different then the result will be 1. besides encryption may be used for exchange the values of two equal-sized variables in this case the advantage is that there is no need for use a third variable.^
Description
par1 ^ par2
Input
- par1 - Any integer
- par2 - Any integer
Output
- Result - Integers
Examples
Example
Bitwise xor the possible of use:x = 123 ^ 25; // x = 98
y = x ^ 25; // y = 123
z = x ^ 123; // z = 25
Example
Even one example in what situations we can use the operation bitwise xor:i ^ j
0xAC ^ k
631 ^ (0xF0 ^ k)
Example
Other pieces of example codes:0x1A ^ 0x1A
xor
Description
par1 xor par2
Input
- par1 - Any integer
- par2 - Any integer
Output
- Result - Integers
Compatible programing languages:
Basic | Visual Basic .NET | FreeBASIC | Free Pascal | Object Pascal | Pascal
Basic | Visual Basic .NET | FreeBASIC | Free Pascal | Object Pascal | Pascal
Examples
Basic
Bitwise xor the possible of use:x = 123 xor 25 ' x = 98
y = x xor 25 ' y = 123
z = x xor 123 ' z = 25
Basic
Even one example in what situations we can use the operation bitwise xor:i xor j
&HAC xor k
631 xor (&HF0 xor k)
Basic
Other pieces of example codes:&H1A xor &H1A
You can find it in the following collections: bitwise operators
Bitwise xor in another programming language: