mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(big): add InsertLowPart
This commit is contained in:
parent
5d875631a6
commit
2b8cc51ad8
3 changed files with 32 additions and 0 deletions
|
|
@ -95,6 +95,10 @@ uint32_t HighBitPos(const BigBuffer& buffer) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void InsertLowPart(uint64_t& value, uint32_t low) {
|
||||
value = (value << 32) | low;
|
||||
}
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high) {
|
||||
return low + (static_cast<uint64_t>(high) << 32);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ void FromUnsigned(BigBuffer& buffer, uint32_t value);
|
|||
|
||||
uint32_t HighBitPos(const BigBuffer& a);
|
||||
|
||||
void InsertLowPart(uint64_t& value, uint32_t low);
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high);
|
||||
|
||||
void Mul(BigBuffer& a, const BigBuffer& b, uint64_t c);
|
||||
|
|
|
|||
26
test/Big.cpp
26
test/Big.cpp
|
|
@ -263,6 +263,32 @@ TEST_CASE("HighBitPos", "[big]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("InsertLowPart", "[big]") {
|
||||
SECTION("inserts low part 0xABCD1111 into value 0") {
|
||||
uint64_t value = 0;
|
||||
uint32_t low = 0xABCD1111;
|
||||
InsertLowPart(value, low);
|
||||
|
||||
CHECK(value == 0xABCD1111);
|
||||
}
|
||||
|
||||
SECTION("inserts low part 0xABCD1111 into value 0xCCCCCCCC") {
|
||||
uint64_t value = 0xCCCCCCCC;
|
||||
uint32_t low = 0xABCD1111;
|
||||
InsertLowPart(value, low);
|
||||
|
||||
CHECK(value == 0xCCCCCCCCABCD1111);
|
||||
}
|
||||
|
||||
SECTION("inserts low part 0x12345678 into value 0xA0B1C2D3E4F5A6B7") {
|
||||
uint64_t value = 0xA0B1C2D3E4F5A6B7;
|
||||
uint32_t low = 0x12345678;
|
||||
InsertLowPart(value, low);
|
||||
|
||||
CHECK(value == 0xE4F5A6B712345678);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Mul", "[big]") {
|
||||
SECTION("multiplies 0 and 1") {
|
||||
BigData* a;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue