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) → int

This operator-bitwise-xor operator of int bit-wise exclusive-or operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe other integer to perform the operation with.


✐ Examples

1 Bit-wise exclusive-or operation with 5 and 3

In this example,

  1. We assign the values 5 and 3 to the integer variables num1 and num2 respectively.
  2. We perform the bit-wise exclusive-or operation between num1 and num2.
  3. 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,

  1. We assign the values 10 and 7 to the integer variables num1 and num2 respectively.
  2. We perform the bit-wise exclusive-or operation between num1 and num2.
  3. 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,

  1. We assign the values 12 and 8 to the integer variables num1 and num2 respectively.
  2. We perform the bit-wise exclusive-or operation between num1 and num2.
  3. 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.