The `remainder()` method returns the remainder of the truncating division of this BigInt by another BigInt.
The syntax of BigInt.remainder() method is:
BigInt remainder(BigInt other)
This remainder() method of BigInt returns the remainder of the truncating division of this
by other
.
Parameter | Optional/Required | Description |
---|---|---|
other | required | the BigInt divisor |
BigInt.remainder() returns value of type BigInt
.
In this example,
dividend
with a value of 10
and a positive divisor BigInt divisor
with a value of 3
.remainder()
method to calculate the remainder of the division of dividend
by divisor
.void main() {
BigInt dividend = BigInt.from(10);
BigInt divisor = BigInt.from(3);
BigInt remainder = dividend.remainder(divisor);
print('Remainder of 10 divided by 3: $remainder');
}
Remainder of 10 divided by 3: 1
In this example,
dividend
with a value of -10
and a positive divisor BigInt divisor
with a value of 3
.remainder()
method to calculate the remainder of the division of dividend
by divisor
.void main() {
BigInt dividend = BigInt.from(-10);
BigInt divisor = BigInt.from(3);
BigInt remainder = dividend.remainder(divisor);
print('Remainder of -10 divided by 3: $remainder');
}
Remainder of -10 divided by 3: -1
In this example,
dividend
with a value of 10
and a negative divisor BigInt divisor
with a value of -3
.remainder()
method to calculate the remainder of the division of dividend
by divisor
.void main() {
BigInt dividend = BigInt.from(10);
BigInt divisor = BigInt.from(-3);
BigInt remainder = dividend.remainder(divisor);
print('Remainder of 10 divided by -3: $remainder');
}
Remainder of 10 divided by -3: 1
In this Dart tutorial, we learned about remainder() method of BigInt: the syntax and few working examples with output and detailed explanation for each example.