abacus: bignum: use base to compute complement
All checks were successful
ci/woodpecker/push/check Pipeline was successful

Instead of hard-coding 9 for base-10 computations.
This commit is contained in:
Bruno BELANYI 2023-12-06 11:54:21 +00:00
parent 8b3288c1ce
commit 2e29dea2b6

View file

@ -107,7 +107,7 @@ digits_type do_substraction(digits_type const& lhs, digits_type const& rhs) {
assert(!do_less_than(lhs, rhs));
digits_type complement;
auto const take_complement = [](auto num) { return 9 - num; };
auto const take_complement = [](auto num) { return BASE - 1 - num; };
std::transform(lhs.begin(), lhs.end(), std::back_inserter(complement),
take_complement);