Fix fallback uint128 bitwise not

This commit is contained in:
Vcode2407 2026-06-16 23:08:57 +05:30 committed by Victor Zverovich
parent 979c94dff8
commit 0ce7d87085
2 changed files with 8 additions and 0 deletions

View File

@ -326,6 +326,9 @@ class uint128 {
-> uint128 {
return {lhs.hi_ & rhs.hi_, lhs.lo_ & rhs.lo_};
}
friend constexpr auto operator~(const uint128& n) -> uint128 {
return {~n.hi_, ~n.lo_};
}
friend FMT_CONSTEXPR auto operator+(const uint128& lhs, const uint128& rhs)
-> uint128 {
auto result = uint128(lhs);

View File

@ -82,6 +82,11 @@ TEST(uint128_test, minus) {
EXPECT_EQ(n - 2, 40);
}
TEST(uint128_test, bitwise_not) {
auto n = ~uint128(0x123456789abcdef0, 0x0fedcba987654321);
EXPECT_EQ(n, uint128(0xedcba9876543210f, 0xf0123456789abcde));
}
TEST(uint128_test, plus_assign) {
auto n = uint128(32);
n += uint128(10);