From cfa19a60ba2cf11c715ec40ce6623d63e3cdce55 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 22 Aug 2021 13:53:22 +0200 Subject: [PATCH] abacus: bignum: trim zeros after a subtraction This way we keep a canonicalized version of the result. --- src/bignum/bignum.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bignum/bignum.cc b/src/bignum/bignum.cc index abf0b5f..ffceaa9 100644 --- a/src/bignum/bignum.cc +++ b/src/bignum/bignum.cc @@ -82,6 +82,8 @@ digits_type do_substraction(digits_type const& lhs, digits_type const& rhs) { std::transform(complement.begin(), complement.end(), complement.begin(), take_complement); + do_trim_leading_zeros(complement); + return complement; }