Dart int operator-bitwise-xor
Syntax & Examples
int.operator-bitwise-xor operator
The `^` operator in Dart performs a bit-wise exclusive-or operation between this integer and another integer.
Syntax of int.operator-bitwise-xor
The syntax of int.operator-bitwise-xor operator is:
operator ^(int other) → intThis operator-bitwise-xor operator of int bit-wise exclusive-or operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The other integer to perform the operation with. |
✐ Examples
1 Bit-wise exclusive-or operation with 5 and 3
In this example,
- We assign the values
5and3to the integer variablesnum1andnum2respectively. - We perform the bit-wise exclusive-or operation between
num1andnum2. - We print the result to standard output.
Dart Program
void main() {
int num1 = 5;
int num2 = 3;
int result = num1 ^ num2;
print('Result of bit-wise exclusive-or operation: $result');
}Output
Result of bit-wise exclusive-or operation: 6
2 Bit-wise exclusive-or operation with 10 and 7
In this example,
- We assign the values
10and7to the integer variablesnum1andnum2respectively. - We perform the bit-wise exclusive-or operation between
num1andnum2. - We print the result to standard output.
Dart Program
void main() {
int num1 = 10;
int num2 = 7;
int result = num1 ^ num2;
print('Result of bit-wise exclusive-or operation: $result');
}Output
Result of bit-wise exclusive-or operation: 13
3 Bit-wise exclusive-or operation with 12 and 8
In this example,
- We assign the values
12and8to the integer variablesnum1andnum2respectively. - We perform the bit-wise exclusive-or operation between
num1andnum2. - We print the result to standard output.
Dart Program
void main() {
int num1 = 12;
int num2 = 8;
int result = num1 ^ num2;
print('Result of bit-wise exclusive-or operation: $result');
}Output
Result of bit-wise exclusive-or operation: 4
Summary
In this Dart tutorial, we learned about operator-bitwise-xor operator of int: the syntax and few working examples with output and detailed explanation for each example.