mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(big): add SBigIsOne
This commit is contained in:
parent
9074869097
commit
c9826d2336
5 changed files with 29 additions and 0 deletions
|
|
@ -77,6 +77,10 @@ int32_t SBigIsOdd(BigData* a) {
|
|||
return IsOdd(a->Primary());
|
||||
}
|
||||
|
||||
int32_t SBigIsOne(BigData* a) {
|
||||
return IsOne(a->Primary());
|
||||
}
|
||||
|
||||
void SBigMod(BigData* a, BigData* b, BigData* c) {
|
||||
uint32_t allocCount = 0;
|
||||
auto& scratch = a->Stack().Alloc(&allocCount);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ int32_t SBigIsEven(BigData* a);
|
|||
|
||||
int32_t SBigIsOdd(BigData* a);
|
||||
|
||||
int32_t SBigIsOne(BigData* a);
|
||||
|
||||
void SBigMod(BigData* a, BigData* b, BigData* c);
|
||||
|
||||
void SBigMul(BigData* a, BigData* b, BigData* c);
|
||||
|
|
|
|||
|
|
@ -220,6 +220,11 @@ int32_t IsOdd(const BigBuffer &num) {
|
|||
return num.Count() != 0 && (num[0] & 1) != 0;
|
||||
}
|
||||
|
||||
int32_t IsOne(const BigBuffer &num) {
|
||||
num.Trim();
|
||||
return num.Count() == 1 && num[0] == 1;
|
||||
}
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high) {
|
||||
return low + (static_cast<uint64_t>(high) << 32);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ int32_t IsEven(const BigBuffer &num);
|
|||
|
||||
int32_t IsOdd(const BigBuffer &num);
|
||||
|
||||
int32_t IsOne(const BigBuffer &num);
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high);
|
||||
|
||||
void Mul(BigBuffer& a, const BigBuffer& b, uint64_t c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue