Dart BigInt pow()
Syntax & Examples
BigInt.pow() method
The `pow` method calculates the power of a big integer to a specified exponent.
Syntax of BigInt.pow()
The syntax of BigInt.pow() method is:
BigInt pow(int exponent)
This pow() method of BigInt returns this
to the power of exponent
.
Parameters
Parameter | Optional/Required | Description |
---|---|---|
exponent | required | the exponent to which to raise the big integer |
Return Type
BigInt.pow() returns value of type BigInt
.
✐ Examples
1 Calculate Power of 225632
In this example,
- We create a BigInt object,
num
, initialized with 225632. - We use the
pow
method to calculate 225632 raised to the power of 5. - We print the result to standard output.
Dart Program
void main() {
BigInt num = BigInt.from(225632);
BigInt result = num.pow(5);
print('$num raised to the power of 5: $result');
}
Output
225632 raised to the power of 5: 584794749865291602232082432
2 Calculate Power of 10
In this example,
- We create a BigInt object,
num
, initialized with 10. - We use the
pow
method to calculate 10 raised to the power of 2. - We print the result to standard output.
Dart Program
void main() {
BigInt num = BigInt.from(10);
BigInt result = num.pow(2);
print('10 raised to the power of 2: $result');
}
Output
10 raised to the power of 2: 100
3 Calculate Power of 5
In this example,
- We create a BigInt object,
num
, initialized with 5. - We use the
pow
method to calculate 5 raised to the power of 4. - We print the result to standard output.
Dart Program
void main() {
BigInt num = BigInt.from(5);
BigInt result = num.pow(4);
print('5 raised to the power of 4: $result');
}
Output
5 raised to the power of 4: 625
Summary
In this Dart tutorial, we learned about pow() method of BigInt: the syntax and few working examples with output and detailed explanation for each example.