From 2e29dea2b6c946466ce3b2c9f56593acf7156bb2 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 6 Dec 2023 11:54:21 +0000 Subject: [PATCH] abacus: bignum: use base to compute complement Instead of hard-coding 9 for base-10 computations. --- src/bignum/bignum.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bignum/bignum.cc b/src/bignum/bignum.cc index 3fce460..f38159f 100644 --- a/src/bignum/bignum.cc +++ b/src/bignum/bignum.cc @@ -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);