Compare commits
3 commits
5c7c2af289
...
8cb26ee316
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 8cb26ee316 | ||
Bruno BELANYI | 4ea7a38b61 | ||
Bruno BELANYI | da8b08e4e3 |
|
@ -4,7 +4,7 @@ enable_testing()
|
||||||
|
|
||||||
add_library(common_options INTERFACE)
|
add_library(common_options INTERFACE)
|
||||||
target_compile_features(common_options INTERFACE
|
target_compile_features(common_options INTERFACE
|
||||||
cxx_std_17
|
cxx_std_20
|
||||||
)
|
)
|
||||||
target_compile_options(common_options INTERFACE
|
target_compile_options(common_options INTERFACE
|
||||||
-Wall
|
-Wall
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <span>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -82,18 +83,17 @@ digits_type do_addition(digits_type const& lhs, digits_type const& rhs) {
|
||||||
++it2;
|
++it2;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = it1;
|
auto leftover = [=]() {
|
||||||
auto end = end1;
|
if (it1 != end1) {
|
||||||
if (it1 == end1) {
|
return std::span(it1, end1);
|
||||||
it = it2;
|
}
|
||||||
end = end2;
|
return std::span(it2, end2);
|
||||||
}
|
}();
|
||||||
|
|
||||||
while (it != end) {
|
for (auto value : leftover) {
|
||||||
int addition = *it + carry;
|
int addition = value + carry;
|
||||||
carry = addition / BASE;
|
carry = addition / BASE;
|
||||||
res.push_back(addition % BASE);
|
res.push_back(addition % BASE);
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (carry != 0) {
|
if (carry != 0) {
|
||||||
|
|
Loading…
Reference in a new issue