This documentation is out of date.
The new version of the documentation is here: https://cannylogic.com/docs |
Difference between revisions of "Bitwise exclusive OR"
From CANNY Wiki
[unchecked revision] | [unchecked revision] |
(6 intermediate revisions by 4 users not shown) | |||
Line 6: | Line 6: | ||
!colspan="2" style="background-color:#AFEEEE;"|Appearance | !colspan="2" style="background-color:#AFEEEE;"|Appearance | ||
|- | |- | ||
− | |colspan="2" align="center" style="padding:10px;"|[[ | + | |colspan="2" align="center" style="padding:10px;"|[[File:5_4_3_2.png]] |
|- | |- | ||
!colspan="2" style="background-color:#AFEEEE;"|Symbol | !colspan="2" style="background-color:#AFEEEE;"|Symbol | ||
Line 14: | Line 14: | ||
!colspan="2" style="background-color:#AFEEEE;"|Group | !colspan="2" style="background-color:#AFEEEE;"|Group | ||
|- | |- | ||
− | |colspan="2" align="center"|[[Built-in Function Blocks | Bitwise operators]] | + | |colspan="2" align="center"|[[Built-in Function Blocks#Bitwise operators | Bitwise operators]] |
|- | |- | ||
!colspan="2" style="background-color:#AFEEEE;"|Inputs | !colspan="2" style="background-color:#AFEEEE;"|Inputs | ||
|- | |- | ||
− | |style="padding-left:1em;"| | + | |style="padding-left:1em;"|Value X: |
− | |style="padding-left:1em;"|[[ | + | |style="padding-left:1em;"|[[CFD Language#Data|Integer]] |
|- | |- | ||
− | |style="padding-left:1em;"| | + | |style="padding-left:1em;"|Value Y: |
− | |style="padding-left:1em;"|[[ | + | |style="padding-left:1em;"|[[CFD Language#Data|Integer]] |
|- | |- | ||
!colspan="2" style="background-color:#AFEEEE;"|Outputs | !colspan="2" style="background-color:#AFEEEE;"|Outputs | ||
|- | |- | ||
|style="padding-left:1em;"|Result: | |style="padding-left:1em;"|Result: | ||
− | |style="padding-left:1em;"|[[ | + | |style="padding-left:1em;"|[[CFD Language#Data|Integer]] |
|- | |- | ||
!colspan="2" style="background-color:#AFEEEE;"|Version [[CANNY Lab]] | !colspan="2" style="background-color:#AFEEEE;"|Version [[CANNY Lab]] | ||
Line 37: | Line 37: | ||
<div style="min-height:100%;display:block;"> | <div style="min-height:100%;display:block;"> | ||
<div style="float:left;width:70px;"> | <div style="float:left;width:70px;"> | ||
− | [[ | + | [[File:5_4_3_1.png|left|Icon]] |
</div> | </div> | ||
<div> | <div> | ||
− | Bitwise modulo 2. Set the output result of XOR operation , applied to each pair of bits that are in the same positions in the binary representation of the input values. | + | Bitwise modulo 2. Set the output as a result of XOR operation , applied to each pair of bits that are in the same positions in the binary representation of the input values. |
</div> | </div> | ||
</div> | </div> | ||
<br clear="left"> | <br clear="left"> | ||
− | In other words, the | + | In other words, the resulting bit is equal to: |
− | *"1" if only one bit of a pair of input | + | *"1" if only one bit of a pair of input values are equal to "1"; |
*"0" if both bits of a pair are equal to "0", or both bits of a pair are equal to "1" | *"0" if both bits of a pair are equal to "0", or both bits of a pair are equal to "1" | ||
Line 54: | Line 54: | ||
{|border="0" style="border-collapse:collapse;" | {|border="0" style="border-collapse:collapse;" | ||
|- | |- | ||
− | |style="padding:5px;"| | + | |style="padding:5px;"|Value X |
|style="padding:5px;"|= | |style="padding:5px;"|= | ||
|style="padding:5px;"|27 | |style="padding:5px;"|27 | ||
Line 62: | Line 62: | ||
|style="padding:5px;"|0b0000000000011011 | |style="padding:5px;"|0b0000000000011011 | ||
|- | |- | ||
− | |style="padding:5px;"| | + | |style="padding:5px;"|Value Y |
|style="padding:5px;"|= | |style="padding:5px;"|= | ||
|style="padding:5px;"|58 | |style="padding:5px;"|58 | ||
Line 81: | Line 81: | ||
== Features == | == Features == | ||
− | + | The result of 'Bitwise XOR' number with itself is always zero. | |
The result of 'Bitwise XOR' on any X with the same Y value twice is always equal to initial X value . | The result of 'Bitwise XOR' on any X with the same Y value twice is always equal to initial X value . | ||
Line 87: | Line 87: | ||
== Examples == | == Examples == | ||
{| | {| | ||
− | |[[ | + | |[[File:5_4_3_3.png|thumb|400px|As decimal]] |
− | |[[ | + | |[[File:5_4_3_4.png|thumb|550px|As binary]] |
|} | |} | ||
Line 106: | Line 106: | ||
[[Right rotation]] | [[Right rotation]] | ||
− | [[ | + | [[Built-in_Function_Blocks | Built-in Function Blocks]] |
Latest revision as of 03:58, 7 April 2016
Appearance | |
---|---|
Symbol | |
X ^ Y | |
Group | |
Bitwise operators | |
Inputs | |
Value X: | Integer |
Value Y: | Integer |
Outputs | |
Result: | Integer |
Version CANNY Lab | |
from 0.6b |
Bitwise modulo 2. Set the output as a result of XOR operation , applied to each pair of bits that are in the same positions in the binary representation of the input values.
In other words, the resulting bit is equal to:
- "1" if only one bit of a pair of input values are equal to "1";
- "0" if both bits of a pair are equal to "0", or both bits of a pair are equal to "1"
For example:
Value X | = | 27 | = | 0x001B | = | 0b0000000000011011 |
Value Y | = | 58 | = | 0x003A | = | 0b0000000000111010 |
Result | = | 33 | = | 0x0021 | = | 0b0000000000100001 |
Features
The result of 'Bitwise XOR' number with itself is always zero.
The result of 'Bitwise XOR' on any X with the same Y value twice is always equal to initial X value .