Documentation ¶
Index ¶
- func StoreUint128BE(b []byte, u Uint128)
- func StoreUint128LE(b []byte, u Uint128)
- type Uint128
- func (u Uint128) Add(v Uint128) Uint128
- func (u Uint128) Add64(v uint64) Uint128
- func (u Uint128) And(v Uint128) Uint128
- func (u Uint128) And64(v uint64) Uint128
- func (u Uint128) AndNot(v Uint128) Uint128
- func (u Uint128) AndNot64(v uint64) Uint128
- func (u Uint128) Big() *big.Int
- func (u Uint128) BitLen() int
- func (u Uint128) Cmp(v Uint128) int
- func (u Uint128) Cmp64(v uint64) int
- func (u Uint128) Div(v Uint128) Uint128
- func (u Uint128) Div64(v uint64) Uint128
- func (u Uint128) Equals(v Uint128) bool
- func (u Uint128) Equals64(v uint64) bool
- func (u Uint128) Format(s fmt.State, ch rune)
- func (u Uint128) IsZero() bool
- func (u Uint128) LeadingZeros() int
- func (u Uint128) Lsh(n uint) Uint128
- func (u Uint128) Mod(v Uint128) Uint128
- func (u Uint128) Mod64(v uint64) uint64
- func (u Uint128) Mul(v Uint128) Uint128
- func (u Uint128) Mul64(v uint64) Uint128
- func (u Uint128) Not() Uint128
- func (u Uint128) OnesCount() int
- func (u Uint128) Or(v Uint128) Uint128
- func (u Uint128) Or64(v uint64) Uint128
- func (u Uint128) QuoRem(v Uint128) (Uint128, Uint128)
- func (u Uint128) QuoRem64(v uint64) (Uint128, uint64)
- func (u Uint128) Reverse() Uint128
- func (u Uint128) ReverseBytes() Uint128
- func (u Uint128) RotateLeft(k int) Uint128
- func (u Uint128) RotateRight(k int) Uint128
- func (u Uint128) Rsh(n uint) Uint128
- func (u Uint128) String() string
- func (u Uint128) Sub(v Uint128) Uint128
- func (u Uint128) Sub64(v uint64) Uint128
- func (u Uint128) TrailingZeros() int
- func (u Uint128) Xor(v Uint128) Uint128
- func (u Uint128) Xor64(v uint64) Uint128
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StoreUint128BE ¶
StoreUint128BE stores 128-bit value in byte slice in big-endian order. It panics if byte slice length is less than 16.
func StoreUint128LE ¶
StoreUint128LE stores 128-bit value in byte slice in little-endian order. It panics if byte slice length is less than 16.
Types ¶
type Uint128 ¶
Uint128 is an unsigned 128-bit number. All methods are immutable, works just like standard uint64.
func FromBig ¶
FromBig converts *big.Int to 128-bit Uint128 value ignoring overflows. If input integer is nil or negative then return Zero. If input interger overflows 128-bit then return Max.
func FromBigX ¶
FromBigX converts *big.Int to 128-bit Uint128 value (eXtended version). Provides ok successful flag as a second return value. If input integer is negative or overflows 128-bit then ok=false. If input if nil then zero 128-bit returned.
func LoadUint128BE ¶
LoadUint128BE loads 128-bit value from byte slice in big-endian order. It panics if byte slice length is less than 16.
func LoadUint128LE ¶
LoadUint128LE loads 128-bit value from byte slice in little-endian order. It panics if byte slice length is less than 16.
func (Uint128) Add ¶
Add returns sum (u+v) of two 128-bit values. Wrap-around semantic is used here: Max().Add(From64(1)) == Zero()
func (Uint128) Add64 ¶
Add64 returns sum u+v of 128-bit and 64-bit values. Wrap-around semantic is used here: Max().Add64(1) == Zero()
func (Uint128) BitLen ¶
BitLen returns the minimum number of bits required to represent 128-bit value. The result is 0 for u == 0.
func (Uint128) Cmp ¶
Cmp compares two 128-bit values and returns:
-1 if u < v 0 if u == v +1 if u > v
func (Uint128) Cmp64 ¶
Cmp64 compares 128-bit and 64-bit values and returns:
-1 if u < v 0 if u == v +1 if u > v
func (Uint128) Equals ¶
Equals returns true if two 128-bit values are equal. Uint128 values can be compared directly with == operator but use of the Equals method is preferred for consistency.
func (Uint128) LeadingZeros ¶
LeadingZeros returns the number of leading zero bits. The result is 128 for u == 0.
func (Uint128) Mul ¶
Mul returns multiplication (u*v) of two 128-bit values. Wrap-around semantic is used here: Max().Mul(Max()) == From64(1).
func (Uint128) Mul64 ¶
Mul64 returns multiplication (u*v) of 128-bit and 64-bit values. Wrap-around semantic is used here: Max().Mul64(2) == Max().Sub64(1).
func (Uint128) QuoRem64 ¶
QuoRem64 returns quotient (u/v) and remainder (u%v) of 128-bit and 64-bit values.
func (Uint128) ReverseBytes ¶
ReverseBytes returns the value with bytes in reversed order.
func (Uint128) RotateLeft ¶
RotateLeft returns the value of u rotated left by (k mod 128) bits.
func (Uint128) RotateRight ¶
RotateRight returns the value of u rotated left by (k mod 128) bits.
func (Uint128) Sub ¶
Sub returns difference (u-v) of two 128-bit values. Wrap-around semantic is used here: Zero().Sub(From64(1)) == Max().
func (Uint128) Sub64 ¶
Sub64 returns difference (u-v) of 128-bit and 64-bit values. Wrap-around semantic is used here: Zero().Sub64(1) == Max().
func (Uint128) TrailingZeros ¶
TrailingZeros returns the number of trailing zero bits. The result is 128 for u == 0.