Documentation ¶
Index ¶
- Variables
- type Int128
- func Int128From64(v int64) Int128
- func Int128FromBigInt(v *big.Int) Int128
- func Int128FromComponents(high, low uint64) Int128
- func Int128FromFloat64(f float64) Int128
- func Int128FromRand(source RandomSource) Int128
- func Int128FromString(s string) (Int128, error)
- func Int128FromStringNoCheck(s string) Int128
- func Int128FromUint64(v uint64) Int128
- func (i Int128) Abs() Int128
- func (i Int128) AbsUint128() Uint128
- func (i Int128) Add(n Int128) Int128
- func (i Int128) Add64(n int64) Int128
- func (i Int128) AsBigFloat() (b *big.Float)
- func (i Int128) AsBigInt() *big.Int
- func (i Int128) AsFloat64() float64
- func (i Int128) AsInt64() int64
- func (i Int128) AsUint128() Uint128
- func (i Int128) AsUint64() uint64
- func (i Int128) Cmp(n Int128) int
- func (i Int128) Cmp64(n int64) int
- func (i Int128) Components() (high, low uint64)
- func (i Int128) Dec() Int128
- func (i Int128) Div(n Int128) Int128
- func (i Int128) Div64(n int64) Int128
- func (i Int128) DivMod(n Int128) (q, r Int128)
- func (i Int128) DivMod64(n int64) (q, r Int128)
- func (i Int128) Equal(n Int128) bool
- func (i Int128) Equal64(n int64) bool
- func (i Int128) Float64() (float64, error)
- func (i Int128) Format(s fmt.State, c rune)
- func (i Int128) GreaterOrEqualTo(n Int128) bool
- func (i Int128) GreaterOrEqualTo64(n int64) bool
- func (i Int128) GreaterThan(n Int128) bool
- func (i Int128) GreaterThan64(n int64) bool
- func (i Int128) Inc() Int128
- func (i Int128) Int64() (int64, error)
- func (i Int128) IsInt64() bool
- func (i Int128) IsUint128() bool
- func (i Int128) IsUint64() bool
- func (i Int128) IsZero() bool
- func (i Int128) LessOrEqualTo(n Int128) bool
- func (i Int128) LessOrEqualTo64(n int64) bool
- func (i Int128) LessThan(n Int128) bool
- func (i Int128) LessThan64(n int64) bool
- func (i Int128) MarshalJSON() ([]byte, error)
- func (i Int128) MarshalText() ([]byte, error)
- func (i Int128) MarshalYAML() (interface{}, error)
- func (i Int128) Mod(n Int128) (r Int128)
- func (i Int128) Mod64(n int64) (r Int128)
- func (i Int128) Mul(n Int128) Int128
- func (i Int128) Mul64(n int64) Int128
- func (i Int128) Neg() Int128
- func (i *Int128) Scan(state fmt.ScanState, verb rune) error
- func (i Int128) Sign() int
- func (i Int128) String() string
- func (i Int128) Sub(n Int128) Int128
- func (i Int128) Sub64(n int64) Int128
- func (i Int128) ToBigInt(b *big.Int)
- func (i *Int128) UnmarshalJSON(in []byte) error
- func (i *Int128) UnmarshalText(text []byte) (err error)
- func (i *Int128) UnmarshalYAML(unmarshal func(interface{}) error) error
- type RandomSource
- type Uint128
- func Uint128From64(v uint64) Uint128
- func Uint128FromBigInt(v *big.Int) Uint128
- func Uint128FromComponents(high, low uint64) Uint128
- func Uint128FromFloat64(f float64) Uint128
- func Uint128FromRand(source RandomSource) Uint128
- func Uint128FromString(s string) (Uint128, error)
- func Uint128FromStringNoCheck(s string) Uint128
- func (u Uint128) Add(n Uint128) Uint128
- func (u Uint128) Add64(n uint64) Uint128
- func (u Uint128) And(n Uint128) Uint128
- func (u Uint128) And64(n uint64) Uint128
- func (u Uint128) AndNot(n Uint128) Uint128
- func (u Uint128) AndNot64(n Uint128) Uint128
- func (u Uint128) AsBigFloat() *big.Float
- func (u Uint128) AsBigInt() *big.Int
- func (u Uint128) AsFloat64() float64
- func (u Uint128) AsInt128() Int128
- func (u Uint128) AsUint64() uint64
- func (u Uint128) Bit(i int) uint
- func (u Uint128) BitLen() int
- func (u Uint128) Cmp(n Uint128) int
- func (u Uint128) Cmp64(n uint64) int
- func (u Uint128) Components() (high, low uint64)
- func (u Uint128) Dec() Uint128
- func (u Uint128) Div(n Uint128) Uint128
- func (u Uint128) Div64(n uint64) Uint128
- func (u Uint128) DivMod(n Uint128) (q, r Uint128)
- func (u Uint128) DivMod64(n uint64) (q, r Uint128)
- func (u Uint128) Equal(n Uint128) bool
- func (u Uint128) Equal64(n uint64) bool
- func (u Uint128) Float64() (float64, error)
- func (u Uint128) Format(s fmt.State, c rune)
- func (u Uint128) GreaterOrEqualTo(n Uint128) bool
- func (u Uint128) GreaterOrEqualTo64(n uint64) bool
- func (u Uint128) GreaterThan(n Uint128) bool
- func (u Uint128) GreaterThan64(n uint64) bool
- func (u Uint128) Inc() Uint128
- func (u Uint128) Int64() (int64, error)
- func (u Uint128) IsInt128() bool
- func (u Uint128) IsUint64() bool
- func (u Uint128) IsZero() bool
- func (u Uint128) LeadingZeros() uint
- func (u Uint128) LeftShift(n uint) Uint128
- func (u Uint128) LessOrEqualTo(n Uint128) bool
- func (u Uint128) LessOrEqualTo64(n uint64) bool
- func (u Uint128) LessThan(n Uint128) bool
- func (u Uint128) LessThan64(n uint64) bool
- func (u Uint128) MarshalJSON() ([]byte, error)
- func (u Uint128) MarshalText() ([]byte, error)
- func (u Uint128) MarshalYAML() (interface{}, error)
- func (u Uint128) Mod(n Uint128) Uint128
- func (u Uint128) Mod64(n uint64) Uint128
- func (u Uint128) Mul(n Uint128) Uint128
- func (u Uint128) Mul64(n uint64) (dest Uint128)
- func (u Uint128) Not() Uint128
- func (u Uint128) OnesCount() int
- func (u Uint128) Or(n Uint128) Uint128
- func (u Uint128) Or64(n uint64) Uint128
- func (u Uint128) RightShift(n uint) Uint128
- func (u *Uint128) Scan(state fmt.ScanState, verb rune) error
- func (u Uint128) SetBit(i int, b uint) Uint128
- func (u Uint128) String() string
- func (u Uint128) Sub(n Uint128) Uint128
- func (u Uint128) Sub64(n uint64) Uint128
- func (u Uint128) ToBigInt(b *big.Int)
- func (u Uint128) TrailingZeros() uint
- func (u *Uint128) UnmarshalJSON(in []byte) error
- func (u *Uint128) UnmarshalText(text []byte) (err error)
- func (u *Uint128) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (u Uint128) Xor(n Uint128) Uint128
- func (u Uint128) Xor64(n uint64) Uint128
Constants ¶
This section is empty.
Variables ¶
var ( // MaxInt128 is the maximum value representable by an Int128. MaxInt128 = Int128{/* contains filtered or unexported fields */} // MinInt128 is the minimum value representable by an Int128. MinInt128 = Int128{/* contains filtered or unexported fields */} )
var ( // MaxUint128 is the maximum value representable by a Uint128. MaxUint128 = Uint128{/* contains filtered or unexported fields */} )
Functions ¶
This section is empty.
Types ¶
type Int128 ¶
type Int128 struct {
// contains filtered or unexported fields
}
Int128 represents a signed 128-bit integer.
func Int128From64 ¶
Int128From64 creates an Int128 from an int64 value.
func Int128FromBigInt ¶
Int128FromBigInt creates an Int128 from a big.Int.
func Int128FromComponents ¶
Int128FromComponents creates an Int128 from two uint64 values representing the high and low bits.
func Int128FromFloat64 ¶
Int128FromFloat64 creates an Int128 from a float64 value.
func Int128FromRand ¶
func Int128FromRand(source RandomSource) Int128
Int128FromRand generates a signed 128-bit random integer.
func Int128FromString ¶
Int128FromString creates an Int128 from a string.
func Int128FromStringNoCheck ¶
Int128FromStringNoCheck creates an Int128 from a string. Unlike Int128FromString, this allows any string as input.
func Int128FromUint64 ¶
Int128FromUint64 creates an Int128 from a uint64 value.
func (Int128) AbsUint128 ¶
AbsUint128 returns the absolute value of i as a Uint128.
func (Int128) AsBigFloat ¶
AsBigFloat returns the Int128 as a big.Float.
func (Int128) Components ¶
Components returns the two uint64 values representing the high and low bits.
func (Int128) DivMod ¶
DivMod returns both the result of i / n as well i % n. If n == 0, a divide by zero panic will occur.
func (Int128) DivMod64 ¶
DivMod64 returns both the result of i / n as well i % n. If n == 0, a divide by zero panic will occur.
func (Int128) Float64 ¶ added in v1.9.2
Float64 implements json.Number. Intentionally always returns an error, as we never want to emit floating point values into json for Int128.
func (Int128) GreaterOrEqualTo ¶
GreaterOrEqualTo returns true if i >= n.
func (Int128) GreaterOrEqualTo64 ¶
GreaterOrEqualTo64 returns true if i >= n.
func (Int128) GreaterThan ¶
GreaterThan returns true if i > n.
func (Int128) GreaterThan64 ¶
GreaterThan64 returns true if i > n.
func (Int128) IsInt64 ¶
IsInt64 returns true if this value can be represented as an int64 without any loss.
func (Int128) IsUint128 ¶
IsUint128 returns true if this value can be represented as an Uint128 without any loss.
func (Int128) IsUint64 ¶
IsUint64 returns true if this value can be represented as a uint64 without any loss.
func (Int128) LessOrEqualTo ¶
LessOrEqualTo returns true if i <= n.
func (Int128) LessOrEqualTo64 ¶
LessOrEqualTo64 returns true if i <= n.
func (Int128) LessThan64 ¶
LessThan64 returns true if i < n.
func (Int128) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Int128) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (Int128) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (*Int128) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Int128) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
func (*Int128) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
type RandomSource ¶
type RandomSource interface {
Uint64() uint64
}
RandomSource defines the method required of a source of random bits. This is a subset of the rand.Source64 interface.
type Uint128 ¶
type Uint128 struct {
// contains filtered or unexported fields
}
Uint128 represents an unsigned 128-bit integer.
func Uint128From64 ¶
Uint128From64 creates a Uint128 from a uint64 value.
func Uint128FromBigInt ¶
Uint128FromBigInt creates a Uint128 from a big.Int.
func Uint128FromComponents ¶
Uint128FromComponents creates a Uint128 from two uint64 values representing the high and low bits.
func Uint128FromFloat64 ¶
Uint128FromFloat64 creates a Uint128 from a float64 value.
func Uint128FromRand ¶
func Uint128FromRand(source RandomSource) Uint128
Uint128FromRand generates an unsigned 128-bit random integer.
func Uint128FromString ¶
Uint128FromString creates a Uint128 from a string.
func Uint128FromStringNoCheck ¶
Uint128FromStringNoCheck creates a Uint128 from a string. Unlike Uint128FromString, this allows any string as input.
func (Uint128) AsBigFloat ¶
AsBigFloat returns the Uint128 as a big.Float.
func (Uint128) Bit ¶
Bit returns the value of the i'th bit of x. That is, it returns (x>>i)&1. If the bit index is less than 0 or greater than 127, zero will be returned.
func (Uint128) BitLen ¶
BitLen returns the length of the absolute value of u in bits. The bit length of 0 is 0.
func (Uint128) Components ¶
Components returns the two uint64 values representing the high and low bits.
func (Uint128) DivMod ¶
DivMod returns both the result of u / n as well u % n. If n == 0, a divide by zero panic will occur.
func (Uint128) DivMod64 ¶
DivMod64 returns both the result of u / n as well u % n. If n == 0, a divide by zero panic will occur.
func (Uint128) Float64 ¶ added in v1.9.2
Float64 implements json.Number. Intentionally always returns an error, as we never want to emit floating point values into json for Uint128.
func (Uint128) GreaterOrEqualTo ¶
GreaterOrEqualTo returns true if u >= n.
func (Uint128) GreaterOrEqualTo64 ¶
GreaterOrEqualTo64 returns true if u >= n.
func (Uint128) GreaterThan ¶
GreaterThan returns true if u > n.
func (Uint128) GreaterThan64 ¶
GreaterThan64 returns true if u > n.
func (Uint128) IsInt128 ¶
IsInt128 returns true if this value can be represented as an Int128 without any loss.
func (Uint128) IsUint64 ¶
IsUint64 returns true if this value can be represented as a uint64 without any loss.
func (Uint128) LeadingZeros ¶
LeadingZeros returns the number of leading bits set to 0.
func (Uint128) LessOrEqualTo ¶
LessOrEqualTo returns true if u <= n.
func (Uint128) LessOrEqualTo64 ¶
LessOrEqualTo64 returns true if u <= n.
func (Uint128) LessThan64 ¶
LessThan64 returns true if u < n.
func (Uint128) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Uint128) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (Uint128) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (Uint128) SetBit ¶
SetBit returns a Uint128 with u's i'th bit set to b (0 or 1). Values of b that are not 0 will be treated as 1. If the bit index is less than 0 or greater than 127, nothing will happen.
func (Uint128) TrailingZeros ¶
TrailingZeros returns the number of trailing bits set to 0.
func (*Uint128) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Uint128) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
func (*Uint128) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.