Documentation ¶
Index ¶
- Variables
- type Uint128
- func (u Uint128) Add(v Uint128) Uint128
- func (u Uint128) Add64(v uint64) Uint128
- func (u Uint128) AddWrap(v Uint128) Uint128
- func (u Uint128) AddWrap64(v uint64) Uint128
- func (u Uint128) And(v Uint128) Uint128
- func (u Uint128) And64(v uint64) Uint128
- func (u Uint128) Big() *big.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) IsZero() bool
- func (u Uint128) LeadingZeros() int
- func (u Uint128) Len() int
- func (u Uint128) Lsh(n uint) (s Uint128)
- func (u Uint128) Mod(v Uint128) (r Uint128)
- func (u Uint128) Mod64(v uint64) (r uint64)
- func (u Uint128) Mul(v Uint128) Uint128
- func (u Uint128) Mul64(v uint64) Uint128
- func (u Uint128) MulWrap(v Uint128) Uint128
- func (u Uint128) MulWrap64(v uint64) Uint128
- func (u Uint128) OnesCount() int
- func (u Uint128) Or(v Uint128) Uint128
- func (u Uint128) Or64(v uint64) Uint128
- func (u Uint128) PutBytes(b []byte)
- func (u Uint128) PutBytesBE(b []byte)
- func (u Uint128) QuoRem(v Uint128) (q, r Uint128)
- func (u Uint128) QuoRem64(v uint64) (q Uint128, r 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) (s Uint128)
- func (u *Uint128) Scan(s fmt.ScanState, ch rune) error
- func (u Uint128) String() string
- func (u Uint128) Sub(v Uint128) Uint128
- func (u Uint128) Sub64(v uint64) Uint128
- func (u Uint128) SubWrap(v Uint128) Uint128
- func (u Uint128) SubWrap64(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 ¶
Max is the largest possible uint128 value.
Functions ¶
This section is empty.
Types ¶
type Uint128 ¶
type Uint128 struct {
Lo, Hi uint64
}
A Uint128 is an unsigned 128-bit number.
var Zero Uint128
Zero is a zero-valued uint128.
func FromBig ¶
FromBig converts i to a Uint128 value. It panics if i is negative or overflows 128 bits.
func FromBytesBE ¶ added in v1.3.0
FromBytesBE converts big-endian b to a Uint128 value.
func FromString ¶ added in v1.2.0
FromString parses s as a Uint128 value.
func (Uint128) AddWrap ¶ added in v1.1.0
AddWrap returns u+v with wraparound semantics; for example, Max.AddWrap(From64(1)) == Zero.
func (Uint128) AddWrap64 ¶ added in v1.1.0
AddWrap64 returns u+v with wraparound semantics; for example, Max.AddWrap64(1) == Zero.
func (Uint128) Equals ¶
Equals returns true if u == v.
Uint128 values can be compared directly with ==, but use of the Equals method is preferred for consistency.
func (Uint128) LeadingZeros ¶ added in v1.1.0
LeadingZeros returns the number of leading zero bits in u; the result is 128 for u == 0.
func (Uint128) Len ¶ added in v1.1.0
Len returns the minimum number of bits required to represent u; the result is 0 for u == 0.
func (Uint128) MulWrap ¶ added in v1.1.0
MulWrap returns u*v with wraparound semantics; for example, Max.MulWrap(Max) == 1.
func (Uint128) MulWrap64 ¶ added in v1.1.0
MulWrap64 returns u*v with wraparound semantics; for example, Max.MulWrap64(2) == Max.Sub64(1).
func (Uint128) OnesCount ¶ added in v1.1.0
OnesCount returns the number of one bits ("population count") in u.
func (Uint128) PutBytesBE ¶ added in v1.3.0
PutBytesBE stores u in b in big-endian order. It panics if len(ip) < 16.
func (Uint128) Reverse ¶ added in v1.1.0
Reverse returns the value of u with its bits in reversed order.
func (Uint128) ReverseBytes ¶ added in v1.1.0
ReverseBytes returns the value of u with its bytes in reversed order.
func (Uint128) RotateLeft ¶ added in v1.1.0
RotateLeft returns the value of u rotated left by (k mod 128) bits.
func (Uint128) RotateRight ¶ added in v1.1.0
RotateRight returns the value of u rotated left by (k mod 128) bits.
func (Uint128) SubWrap ¶ added in v1.1.0
SubWrap returns u-v with wraparound semantics; for example, Zero.SubWrap(From64(1)) == Max.
func (Uint128) SubWrap64 ¶ added in v1.1.0
SubWrap64 returns u-v with wraparound semantics; for example, Zero.SubWrap64(1) == Max.
func (Uint128) TrailingZeros ¶ added in v1.1.0
TrailingZeros returns the number of trailing zero bits in u; the result is 128 for u == 0.