Dart BigInt operator-multiplication
Syntax & Examples
BigInt.operator-multiplication operator
The `operator *` in Dart performs multiplication between two BigInt objects.
Syntax of BigInt.operator-multiplication
The syntax of BigInt.operator-multiplication operator is:
operator *(BigInt other) → BigIntThis operator-multiplication operator of BigInt multiplication operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | the BigInt object to multiply with |
✐ Examples
1 Multiply Positive BigInts
In this example,
- We create two BigInt objects,
num1andnum2, initialized with positive integers. - We use the
*operator to multiplynum1bynum2. - We print the result of the multiplication to standard output.
Dart Program
void main() {
BigInt num1 = BigInt.from(5);
BigInt num2 = BigInt.from(3);
BigInt result = num1 * num2;
print('Result of multiplication: $result');
}Output
Result of multiplication: 15
2 Multiply Positive and Negative BigInts
In this example,
- We create two BigInt objects,
num1andnum2, initialized with positive and negative integers, respectively. - We use the
*operator to multiplynum1bynum2. - We print the result of the multiplication to standard output.
Dart Program
void main() {
BigInt num1 = BigInt.from(10);
BigInt num2 = BigInt.from(-2);
BigInt result = num1 * num2;
print('Result of multiplication: $result');
}Output
Result of multiplication: -20
3 Multiply Negative BigInts
In this example,
- We create two BigInt objects,
num1andnum2, initialized with negative integers. - We use the
*operator to multiplynum1bynum2. - We print the result of the multiplication to standard output.
Dart Program
void main() {
BigInt num1 = BigInt.from(-4);
BigInt num2 = BigInt.from(-6);
BigInt result = num1 * num2;
print('Result of multiplication: $result');
}Output
Result of multiplication: 24
Summary
In this Dart tutorial, we learned about operator-multiplication operator of BigInt: the syntax and few working examples with output and detailed explanation for each example.