Documentation ¶
Index ¶
- Variables
- type Uint128
- func (u Uint128) Add(v Uint128) Uint128
- func (u Uint128) Add64(v uint64) Uint128
- func (u Uint128) Add64Overflow(v uint64) (Uint128, bool)
- func (u Uint128) AddOverflow(v Uint128) (Uint128, bool)
- 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) IsUint16() bool
- func (u Uint128) IsUint32() bool
- func (u Uint128) IsUint64() bool
- func (u Uint128) IsUint8() 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) MarshalJSON() ([]byte, error)
- func (u Uint128) MarshalText() ([]byte, error)
- 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) Mul64Overflow(v uint64) (Uint128, bool)
- func (u Uint128) MulOverflow(v Uint128) (Uint128, bool)
- 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) Sub64Overflow(v uint64) (Uint128, bool)
- func (u Uint128) SubOverflow(v Uint128) (Uint128, bool)
- func (u Uint128) SubWrap(v Uint128) Uint128
- func (u Uint128) SubWrap64(v uint64) Uint128
- func (u Uint128) TrailingZeros() int
- func (u Uint128) Uint16() uint16
- func (u Uint128) Uint32() uint32
- func (u Uint128) Uint64() uint64
- func (u Uint128) Uint8() uint8
- func (u *Uint128) UnmarshalJSON(data []byte) error
- func (u *Uint128) UnmarshalText(text []byte) error
- func (u Uint128) Xor(v Uint128) Uint128
- func (u Uint128) Xor64(v uint64) Uint128
Constants ¶
This section is empty.
Variables ¶
var ( ErrValueNegative = errors.New("value cannot be negative") ErrValueOverflow = errors.New("value overflows Uint128") )
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 ¶
FromBytesBE converts big-endian b to a Uint128 value.
func FromString ¶
FromString parses s as a Uint128 value.
func (Uint128) Add64Overflow ¶
Add64 returns u+v. The second return value is true if the result overflows.
func (Uint128) AddOverflow ¶
Add returns u+v. The second return value is true if the result overflows.
func (Uint128) AddWrap ¶
AddWrap returns u+v with wraparound semantics; for example, Max.AddWrap(From64(1)) == Zero.
func (Uint128) AddWrap64 ¶
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) IsUint16 ¶ added in v1.2.0
Uint returns true if u can be safely represented as a uint16.
func (Uint128) IsUint32 ¶ added in v1.2.0
Uint returns true if u can be safely represented as a uint32.
func (Uint128) IsUint64 ¶ added in v1.2.0
Uint returns true if u can be safely represented as a uint64.
func (Uint128) IsUint8 ¶ added in v1.2.0
Uint returns true if u can be safely represented as a uint8.
func (Uint128) LeadingZeros ¶
LeadingZeros returns the number of leading zero bits in u; the result is 128 for u == 0.
func (Uint128) Len ¶
Len returns the minimum number of bits required to represent u; the result is 0 for u == 0.
func (Uint128) MarshalJSON ¶ added in v1.3.0
MarshalJSON implements json.Marshaler.
func (Uint128) MarshalText ¶ added in v1.3.0
MarshalText implements encoding.TextMarshaler.
func (Uint128) Mul64Overflow ¶
Mul64 returns u*v, panicking on overflow.
func (Uint128) MulOverflow ¶
Mul returns u*v, panicking on overflow.
func (Uint128) MulWrap ¶
MulWrap returns u*v with wraparound semantics; for example, Max.MulWrap(Max) == 1.
func (Uint128) MulWrap64 ¶
MulWrap64 returns u*v with wraparound semantics; for example, Max.MulWrap64(2) == Max.Sub64(1).
func (Uint128) PutBytesBE ¶
PutBytesBE stores u in b in big-endian order. It panics if len(ip) < 16.
func (Uint128) ReverseBytes ¶
ReverseBytes returns the value of u with its 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) Sub64Overflow ¶
Sub64 returns u-v. The second return value is true if the result underflows.
func (Uint128) SubOverflow ¶
Sub returns u-v. The second return value is true if the result underflows.
func (Uint128) SubWrap ¶
SubWrap returns u-v with wraparound semantics; for example, Zero.SubWrap(From64(1)) == Max.
func (Uint128) SubWrap64 ¶
SubWrap64 returns u-v with wraparound semantics; for example, Zero.SubWrap64(1) == Max.
func (Uint128) TrailingZeros ¶
TrailingZeros returns the number of trailing zero bits in u; the result is 128 for u == 0.
func (*Uint128) UnmarshalJSON ¶ added in v1.3.0
UnmarshalJSON implements json.Unmarshaler.
func (*Uint128) UnmarshalText ¶ added in v1.3.0
UnmarshalText implements encoding.TextUnmarshaler.