|
VLink 2.0.0
A high-performance communication middleware
|
128-bit unsigned integer stored as two 64-bit halves with full operator support. More...
#include <uint128.h>
Public Member Functions | |
| Uint128 () noexcept=default | |
Default-constructs a zero-valued Uint128. | |
| template<typename T> | |
| constexpr | Uint128 (T v) noexcept |
Constructs a Uint128 from any integral type T (implicit conversion). | |
| Uint128 (uint64_t high, uint64_t low) noexcept | |
Constructs a Uint128 from explicit high and low 64-bit halves. | |
| Uint128 | operator+ (const Uint128 &other) const noexcept |
Returns the sum of *this and other. | |
| Uint128 | operator- (const Uint128 &other) const noexcept |
Returns the difference of *this and other. | |
| Uint128 | operator* (const Uint128 &other) const noexcept |
Returns the product of *this and other. | |
| Uint128 | operator/ (const Uint128 &other) const |
Returns the quotient of *this divided by other. | |
| Uint128 | operator% (const Uint128 &other) const |
Returns the remainder of *this divided by other. | |
| Uint128 & | operator+= (const Uint128 &other) noexcept |
Adds other to *this in-place with carry propagation. | |
| Uint128 & | operator-= (const Uint128 &other) noexcept |
Subtracts other from *this in-place with borrow propagation. | |
| Uint128 & | operator*= (const Uint128 &other) noexcept |
Multiplies *this by other in-place. | |
| Uint128 & | operator/= (const Uint128 &other) |
Divides *this by other in-place. | |
| Uint128 & | operator%= (const Uint128 &other) |
Computes *this modulo other in-place. | |
| Uint128 | operator| (const Uint128 &other) const noexcept |
Returns the bitwise OR of *this and other. | |
| Uint128 | operator& (const Uint128 &other) const noexcept |
Returns the bitwise AND of *this and other. | |
| Uint128 | operator^ (const Uint128 &other) const noexcept |
Returns the bitwise XOR of *this and other. | |
| Uint128 | operator~ () const noexcept |
Returns the bitwise NOT (complement) of *this. | |
| Uint128 | operator<< (int shift) const noexcept |
Returns *this shifted left by shift bits. | |
| Uint128 | operator>> (int shift) const noexcept |
Returns *this shifted right by shift bits (logical, zero-fill). | |
| Uint128 & | operator|= (const Uint128 &other) noexcept |
Applies bitwise OR with other in-place. | |
| Uint128 & | operator&= (const Uint128 &other) noexcept |
Applies bitwise AND with other in-place. | |
| Uint128 & | operator^= (const Uint128 &other) noexcept |
Applies bitwise XOR with other in-place. | |
| Uint128 & | operator<<= (int shift) noexcept |
Shifts *this left by shift bits in-place. | |
| Uint128 & | operator>>= (int shift) noexcept |
Shifts *this right by shift bits in-place (logical, zero-fill). | |
| bool | operator== (const Uint128 &other) const noexcept |
Returns true if *this equals other. | |
| bool | operator!= (const Uint128 &other) const noexcept |
Returns true if *this does not equal other. | |
| bool | operator< (const Uint128 &other) const noexcept |
Returns true if *this is less than other. | |
| bool | operator> (const Uint128 &other) const noexcept |
Returns true if *this is greater than other. | |
| bool | operator<= (const Uint128 &other) const noexcept |
Returns true if *this is less than or equal to other. | |
| bool | operator>= (const Uint128 &other) const noexcept |
Returns true if *this is greater than or equal to other. | |
| Uint128 & | operator++ () noexcept |
Pre-increment: increments the value by one and returns *this. | |
| Uint128 | operator++ (int) noexcept |
| Post-increment: increments the value by one and returns the previous value. | |
| Uint128 & | operator-- () noexcept |
Pre-decrement: decrements the value by one and returns *this. | |
| Uint128 | operator-- (int) noexcept |
| Post-decrement: decrements the value by one and returns the previous value. | |
| uint64_t | get_high () const noexcept |
| Returns the upper 64 bits of the 128-bit value. | |
| uint64_t | get_low () const noexcept |
| Returns the lower 64 bits of the 128-bit value. | |
Friends | |
| VLINK_EXPORT friend std::ostream & | operator<< (std::ostream &os, const Uint128 &value) noexcept |
Writes the hexadecimal string representation of the value to os. | |
128-bit unsigned integer stored as two 64-bit halves with full operator support.
Stores the value as (high_ << 64) | low_. All arithmetic correctly handles carry/borrow across the 64-bit boundary. Division and modulo are implemented using a portable binary-long-division algorithm (u128_divmod).
|
defaultnoexcept |
Default-constructs a zero-valued Uint128.
|
inlineconstexprnoexcept |
Constructs a Uint128 from any integral type T (implicit conversion).
T is __uint128_t (available on GCC/Clang 64-bit), splits into high and low halves.low_; high_ is set to zero.| T | Source integral type. |
| v | Source value. |
|
inlineexplicitnoexcept |
Constructs a Uint128 from explicit high and low 64-bit halves.
Details.
| high | Upper 64 bits. |
| low | Lower 64 bits. |
|
inlinenodiscardnoexcept |
Returns the upper 64 bits of the 128-bit value.
|
inlinenodiscardnoexcept |
Returns the lower 64 bits of the 128-bit value.
|
inlinenodiscardnoexcept |
Returns true if *this does not equal other.
| other | Right-hand operand. |
true if any word differs. Returns the remainder of *this divided by other.
| other | Divisor. |
Uint128 equal to *this % other.| std::domain_error | (or similar) if other is zero. |
Computes *this modulo other in-place.
| other | Divisor. |
*this.| std::domain_error | (or similar) if other is zero. |
Returns the bitwise AND of *this and other.
| other | Right-hand operand. |
Uint128 with each bit set only if set in both operands. Applies bitwise AND with other in-place.
| other | Right-hand operand. |
*this. Returns the product of *this and other.
Uses __uint128_t multiplication when available; falls back to mul_u128_fallback otherwise.
| other | Right-hand operand. |
Uint128 equal to *this * other (low 128 bits of true product). Multiplies *this by other in-place.
| other | Right-hand operand. |
*this. Returns the sum of *this and other.
| other | Right-hand operand. |
Uint128 equal to *this + other.
|
inlinenoexcept |
Pre-increment: increments the value by one and returns *this.
Carry from the low word is propagated to the high word.
|
inlinenoexcept |
Post-increment: increments the value by one and returns the previous value.
Adds other to *this in-place with carry propagation.
| other | Right-hand operand. |
*this. Returns the difference of *this and other.
| other | Right-hand operand. |
Uint128 equal to *this - other (wraps on underflow).
|
inlinenoexcept |
Pre-decrement: decrements the value by one and returns *this.
Borrow from the low word underflow is propagated to the high word.
|
inlinenoexcept |
Post-decrement: decrements the value by one and returns the previous value.
Subtracts other from *this in-place with borrow propagation.
| other | Right-hand operand. |
*this. Returns the quotient of *this divided by other.
| other | Divisor. |
Uint128 equal to *this / other.| std::domain_error | (or similar) if other is zero. |
Divides *this by other in-place.
| other | Divisor. |
*this.| std::domain_error | (or similar) if other is zero. |
|
inlinenodiscardnoexcept |
Returns true if *this is less than other.
Compares the high word first; if equal, compares the low word.
| other | Right-hand operand. |
true if *this < other.
|
inlinenoexcept |
Returns *this shifted left by shift bits.
*this unchanged.| shift | Number of bit positions to shift left. |
|
inlinenoexcept |
Shifts *this left by shift bits in-place.
| shift | Number of bit positions to shift left. |
*this.
|
inlinenodiscardnoexcept |
Returns true if *this is less than or equal to other.
| other | Right-hand operand. |
true if *this <= other.
|
inlinenodiscardnoexcept |
Returns true if *this equals other.
| other | Right-hand operand. |
true if high and low words are both equal.
|
inlinenodiscardnoexcept |
Returns true if *this is greater than other.
| other | Right-hand operand. |
true if *this > other.
|
inlinenodiscardnoexcept |
Returns true if *this is greater than or equal to other.
| other | Right-hand operand. |
true if *this >= other.
|
inlinenoexcept |
Returns *this shifted right by shift bits (logical, zero-fill).
*this unchanged.| shift | Number of bit positions to shift right. |
|
inlinenoexcept |
Shifts *this right by shift bits in-place (logical, zero-fill).
| shift | Number of bit positions to shift right. |
*this. Returns the bitwise XOR of *this and other.
| other | Right-hand operand. |
Uint128 with each bit set if it differs between operands. Applies bitwise XOR with other in-place.
| other | Right-hand operand. |
*this. Returns the bitwise OR of *this and other.
| other | Right-hand operand. |
Uint128 with each bit set if it is set in either operand. Applies bitwise OR with other in-place.
| other | Right-hand operand. |
*this.
|
inlinenoexcept |
Returns the bitwise NOT (complement) of *this.
Uint128 with all 128 bits inverted.
|
friend |
Writes the hexadecimal string representation of the value to os.
| os | Output stream. |
| value | Value to print. |
os.