Dart int operator-bitwise-and
Syntax & Examples


int.operator-bitwise-and operator

The `&` operator in Dart performs a bit-wise AND operation between two integers.


Syntax of int.operator-bitwise-and

The syntax of int.operator-bitwise-and operator is:

operator &(int other) → int

This operator-bitwise-and operator of int bit-wise and operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe other integer to perform the bit-wise AND operation with.


✐ Examples

1 Bit-wise AND operation

In this example,

  1. We create two integer variables num1 and num2 with values 5 and 3 respectively.
  2. We use the `&` operator to perform the bit-wise AND operation between num1 and num2.
  3. We then print the result to standard output.

Dart Program

void main() {
  int num1 = 5;
  int num2 = 3;
  int result = num1 & num2;
  print('Bit-wise AND of $num1 and $num2: $result');
}

Output

Bit-wise AND of 5 and 3: 1

2 Bit-wise AND operation

In this example,

  1. We create two integer variables num3 and num4 with values 10 and 6 respectively.
  2. We use the `&` operator to perform the bit-wise AND operation between num3 and num4.
  3. We then print the result to standard output.

Dart Program

void main() {
  int num3 = 10;
  int num4 = 6;
  int result = num3 & num4;
  print('Bit-wise AND of $num3 and $num4: $result');
}

Output

Bit-wise AND of 10 and 6: 2

3 Bit-wise AND operation

In this example,

  1. We create two integer variables num5 and num6 with values 15 and 9 respectively.
  2. We use the `&` operator to perform the bit-wise AND operation between num5 and num6.
  3. We then print the result to standard output.

Dart Program

void main() {
  int num5 = 15;
  int num6 = 9;
  int result = num5 & num6;
  print('Bit-wise AND of $num5 and $num6: $result');
}

Output

Bit-wise AND of 15 and 9: 9

Summary

In this Dart tutorial, we learned about operator-bitwise-and operator of int: the syntax and few working examples with output and detailed explanation for each example.