feat(big): add SBigAdd

This commit is contained in:
fallenoak 2023-01-29 22:12:59 -06:00 committed by GitHub
parent 6c83070380
commit 33585cb36f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 0 deletions

View file

@ -1,5 +1,16 @@
#include "storm/big/Ops.hpp"
void Add(BigBuffer& a, const BigBuffer& b, const BigBuffer& c) {
uint64_t carry = 0;
uint32_t i = 0;
for (i = 0; carry || b.IsUsed(i) || c.IsUsed(i); i++) {
carry += static_cast<uint64_t>(b[i]) + c[i];
a[i] = ExtractLowPart(carry);
}
a.SetCount(i);
}
uint32_t ExtractLowPart(uint64_t& value) {
auto low = static_cast<uint32_t>(value);
value >>= 32;