mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(big): add SBigAdd
This commit is contained in:
parent
6c83070380
commit
33585cb36f
5 changed files with 110 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue