Dart int operator-bitwise-or
Syntax & Examples
int.operator-bitwise-or operator
The `|` operator in Dart performs a bit-wise OR operation between this integer and another integer.
Syntax of int.operator-bitwise-or
The syntax of int.operator-bitwise-or operator is:
operator |(int other) → intThis operator-bitwise-or operator of int bit-wise or operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The other integer to perform the operation with. |
✐ Examples
1 Bit-wise OR operation with 5 and 3
In this example,
- We assign the values
5and3to the integer variablesnum1andnum2respectively. - We perform the bit-wise 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 OR operation: $result');
}Output
Result of bit-wise OR operation: 7
2 Bit-wise OR operation with 10 and 7
In this example,
- We assign the values
10and7to the integer variablesnum1andnum2respectively. - We perform the bit-wise 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 OR operation: $result');
}Output
Result of bit-wise OR operation: 15
3 Bit-wise OR operation with 12 and 8
In this example,
- We assign the values
12and8to the integer variablesnum1andnum2respectively. - We perform the bit-wise 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 OR operation: $result');
}Output
Result of bit-wise OR operation: 12
Summary
In this Dart tutorial, we learned about operator-bitwise-or operator of int: the syntax and few working examples with output and detailed explanation for each example.