brootrem#

Return the integer $n-th root of $x and the shortfall.

Synopsis#

my $x = Math::GMP->new(100);
my ($root, $rem) = $x->brootrem(3);    # 4, 36

## because 4**3 + 36 == 100

The returned list satisfies $root ** $n + $rem == $x exactly. Use when you need both pieces in one pass — calling broot and computing the remainder yourself doubles the work.

Differences from upstream#

Replicates upstream’s explicit workaround for libgmp versions earlier than 5.1.0, where mpz_rootrem returned wrong results for negative arguments with odd $n. Modern libgmp builds skip the workaround automatically.