divmod static method

Tuple<BigInt, BigInt> divmod(
  1. BigInt value,
  2. int radix
)

Divides a BigInt value by a specified radix and returns both the quotient and the remainder.

This method divides a given BigInt value by a specified radix and returns a tuple containing the quotient and the remainder of the division.

Parameters:

  • value: The BigInt value to be divided.
  • radix: The divisor, typically representing a base (e.g., 10 for base 10).

Returns: A tuple of two BigInt values where the first element is the quotient, and the second element is the remainder of the division.

Example:

BigInt number = BigInt.parse('12345');
int radix = 10; // Decimal base
var result = divmod(number, radix);
print('Quotient: ${result.item1}, Remainder: ${result.item2}');

This method is useful for performing division and obtaining both the quotient and the remainder.

Implementation

static Tuple<BigInt, BigInt> divmod(BigInt value, int radix) {
  final div = value ~/ BigInt.from(radix);
  final mod = value % BigInt.from(radix);
  return Tuple(div, mod);
}