mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(big): add SBigSub
This commit is contained in:
parent
6e62f0a604
commit
5d875631a6
5 changed files with 146 additions and 0 deletions
|
|
@ -141,6 +141,19 @@ void SetZero(BigBuffer& buffer) {
|
|||
buffer.Clear();
|
||||
}
|
||||
|
||||
void Sub(BigBuffer& a, const BigBuffer& b, const BigBuffer& c) {
|
||||
uint64_t borrow = 0;
|
||||
uint32_t i = 0;
|
||||
for (i = 0; b.IsUsed(i) || c.IsUsed(i); i++) {
|
||||
borrow += b[i] - static_cast<uint64_t>(c[i]);
|
||||
a[i] = ExtractLowPartSx(borrow);
|
||||
}
|
||||
|
||||
a.SetCount(i);
|
||||
|
||||
STORM_ASSERT(!borrow);
|
||||
}
|
||||
|
||||
void ToBinaryAppend(TSGrowableArray<uint8_t>& output, const BigBuffer& buffer) {
|
||||
for (uint32_t i = 0; i < buffer.Count() * 4; i++) {
|
||||
auto byte = buffer[i / 4] >> (8 * (i & 3));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue