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

This operator-multiplication operator of BigInt multiplication operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe BigInt object to multiply with


✐ Examples

1 Multiply Positive BigInts

In this example,

  1. We create two BigInt objects, num1 and num2, initialized with positive integers.
  2. We use the * operator to multiply num1 by num2.
  3. 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,

  1. We create two BigInt objects, num1 and num2, initialized with positive and negative integers, respectively.
  2. We use the * operator to multiply num1 by num2.
  3. 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,

  1. We create two BigInt objects, num1 and num2, initialized with negative integers.
  2. We use the * operator to multiply num1 by num2.
  3. 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.