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) → intThis operator-bitwise-and operator of int bit-wise and operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The other integer to perform the bit-wise AND operation with. |
✐ Examples
1 Bit-wise AND operation
In this example,
- We create two integer variables
num1andnum2with values 5 and 3 respectively. - We use the `&` operator to perform the bit-wise AND operation between
num1andnum2. - 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,
- We create two integer variables
num3andnum4with values 10 and 6 respectively. - We use the `&` operator to perform the bit-wise AND operation between
num3andnum4. - 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,
- We create two integer variables
num5andnum6with values 15 and 9 respectively. - We use the `&` operator to perform the bit-wise AND operation between
num5andnum6. - 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.