bitwisexor: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 22: | Line 22: | ||
|examples= | |examples= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: | [r: bxor(1,0)] | ||
</source> | </source> | ||
Returns 1. | Returns 1. | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: | [r: bxor(1,1)] | ||
</source> | </source> | ||
Returns 0. | Returns 0. | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: | [r: bxor(0,0)] | ||
</source> | </source> | ||
Returns 0. | Returns 0. | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: | [r: bxor(2, 4] | ||
</source> | </source> | ||
Returns 6. | Returns 6. | ||
Line 43: | Line 43: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: | [r: bxor(6, 4)] | ||
</source> | </source> | ||
Returns 2. | Returns 2. |
Revision as of 12:56, 25 April 2019
bitwisexor() Function
Performs a bitwise 'exlusive or' operation of the number arguments by taking the binary representation of each of the numbers and performing the logical exclusive or operation on each of the bits.
Logical " exclusive or" Table
Bit1 | Bit2 | Result |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 1 | 0 |
Usage
[h: val = bxor(num, num, ...)]
[h: val = bitwisexor(num, num, ...)]
Examples
[r: bxor(1,0)]
Returns 1.
[r: bxor(1,1)]
Returns 0.
[r: bxor(0,0)]
Returns 0.
[r: bxor(2, 4]
Returns 6. 2 in binary is 010 and 4 in binary is 100, so a bitwise xor of these two values is 110 which is 6 in decimal.
[r: bxor(6, 4)]
Returns 2.
6 in binary is 110 and 4 in binary is 100, so a bitwise xor of these two values is 010 which is 2 in decimal.