Documentation
¶
Overview ¶
Package wide provides implementations of Int128 and Uint128 for Go. See README.md for more information.
Index ¶
- type Int128
- func (x Int128) Abs() Int128
- func (x Int128) Add(y Int128) (z Int128)
- func (x Int128) And(y Int128) (z Int128)
- func (x Int128) AndNot(y Int128) (z Int128)
- func (x Int128) Cmp(y Int128) int
- func (x Int128) CmpAbs(y Int128) int
- func (x Int128) Dec() (z Int128)
- func (x Int128) Div(d Int128) (q Int128)
- func (x Int128) DivMod(d Int128) (q, r Int128)
- func (x Int128) Eq(y Int128) bool
- func (x Int128) Gt(y Int128) bool
- func (x Int128) Gte(y Int128) bool
- func (x Int128) Inc() (z Int128)
- func (x Int128) Int64() int64
- func (x Int128) IsInt64() bool
- func (x Int128) IsNeg() bool
- func (x Int128) IsPos() bool
- func (x Int128) IsUint64() bool
- func (x Int128) LShift() (z Int128)
- func (x Int128) LShiftN(n uint) (z Int128)
- func (x Int128) Lt(y Int128) bool
- func (x Int128) Lte(y Int128) bool
- func (x Int128) Mod(d Int128) (r Int128)
- func (x Int128) Mul(y Int128) (z Int128)
- func (x Int128) Nand(y Int128) (z Int128)
- func (x Int128) Neg() (z Int128)
- func (x Int128) Nor(y Int128) (z Int128)
- func (x Int128) Not() (z Int128)
- func (x Int128) Or(y Int128) (z Int128)
- func (x Int128) RShift() (z Int128)
- func (x Int128) RShift128(y Uint128) (z Int128)
- func (x Int128) RShiftN(n uint) (z Int128)
- func (x Int128) Sign() int
- func (x Int128) String() string
- func (x Int128) Sub(y Int128) (z Int128)
- func (x Int128) Uint128() (z Uint128)
- func (x Int128) Uint64() uint64
- func (x Int128) Xnor(y Int128) (z Int128)
- func (x Int128) Xor(y Int128) (z Int128)
- type Uint128
- func (x Uint128) Add(y Uint128) (z Uint128)
- func (x Uint128) And(y Uint128) (z Uint128)
- func (x Uint128) AndNot(y Uint128) (z Uint128)
- func (x Uint128) Cmp(y Uint128) int
- func (x Uint128) Dec() (z Uint128)
- func (x Uint128) Div(d Uint128) (q Uint128)
- func (x Uint128) DivMod(d Uint128) (q, r Uint128)
- func (x Uint128) Eq(y Uint128) bool
- func (x Uint128) Gt(y Uint128) bool
- func (x Uint128) Gte(y Uint128) bool
- func (x Uint128) Inc() (z Uint128)
- func (x Uint128) Int128() (z Int128)
- func (x Uint128) Int64() int64
- func (x Uint128) IsInt64() bool
- func (x Uint128) IsUint64() bool
- func (x Uint128) LShift() (z Uint128)
- func (x Uint128) LShiftN(n uint) (z Uint128)
- func (x Uint128) Len() uint
- func (x Uint128) Lt(y Uint128) bool
- func (x Uint128) Lte(y Uint128) bool
- func (x Uint128) Mod(d Uint128) (r Uint128)
- func (x Uint128) Mul(y Uint128) (z Uint128)
- func (x Uint128) Nand(y Uint128) (z Uint128)
- func (x Uint128) Neg() (z Uint128)
- func (x Uint128) Nor(y Uint128) (z Uint128)
- func (x Uint128) Not() (z Uint128)
- func (x Uint128) Or(y Uint128) (z Uint128)
- func (x Uint128) RShift() (z Uint128)
- func (x Uint128) RShift128(y Uint128) (z Uint128)
- func (x Uint128) RShiftN(n uint) (z Uint128)
- func (x Uint128) String() string
- func (x Uint128) Sub(y Uint128) (z Uint128)
- func (x Uint128) Uint64() uint64
- func (x Uint128) Xnor(y Uint128) (z Uint128)
- func (x Uint128) Xor(y Uint128) (z Uint128)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Int128 ¶
Int128 is a representation of a signed 128-bit integer
func Int128FromBigInt ¶
Int128FromBigInt returns an Int128 from a big.Int
func Int128FromInt64 ¶
Int128FromInt64 returns an Int128 from an int64
func (Int128) CmpAbs ¶
CmpAbs compares |x| and |y| and returns:
-1 if |x| < |y| 0 if |x| == |y| +1 if |x| > |y|
func (Int128) Div ¶
Div returns the quotient corresponding to the provided dividend and divisor
Div panics on division by 0. It checks some common/faster cases before fully committing to long division. This can probably be further optimized by implementing a successive approximation algorithm, with an initial seed value determined by a 64-bit division of the most significant bits.
func (Int128) DivMod ¶
DivMod returns the quotient and remainder corresponding to the provided dividend and divisor
DivMod panics on division by 0. It checks some common/faster cases before fully committing to long division. This can probably be further optimized by implementing a successive approximation algorithm, with an initial seed value determined by a 64-bit division of the most significant bits.
func (Int128) Int64 ¶
Int64 returns a representation of the Int128 as the builtin int64
This function overflows silently
func (Int128) IsUint64 ¶
IsUint64 checks if the Int128 can be represented as a uint64 without wrapping
func (Int128) Mod ¶
Mod returns the remainder corresponding to the provided dividend and divisor
Mod panics on division by 0. It checks some common/faster cases before fully committing to long division. This can probably be further optimized by implementing a successive approximation algorithm, with an initial seed value determined by a 64-bit division of the most significant bits.
func (Int128) RShiftN ¶
RShiftN returns an Int128 right-shifted by a uint (i.e. x >> n)
Could probably be made faster with sign extension
func (Int128) Uint128 ¶
Uint128 returns a Uint128 representation of an Int128
This function overflows silently
func (Int128) Uint64 ¶
Uint64 returns a representation of the Int128 as the builtin uint64
This function overflows silently
type Uint128 ¶
type Uint128 struct {
Hi, Lo uint64
}
Uint128 is a representation of an unsigned 128-bit integer
func NewUint128 ¶
NewUint128 returns a Uint128 from the high and low 64 bits
func Uint128FromBigInt ¶
Uint128FromBigInt returns a Uint128 from a big.Int
func Uint128FromUint64 ¶
Uint128FromUint64 returns a Uint128 from a uint64
func (Uint128) Div ¶
Div returns the quotient corresponding to the provided dividend and divisor
Div panics on division by 0. It checks some common/faster cases before fully committing to long division. This can probably be further optimized by implementing a successive approximation algorithm, with an initial seed value determined by a 64-bit division of the most significant bits.
func (Uint128) DivMod ¶
DivMod returns the quotient and remainder corresponding to the provided dividend and divisor
DivMod panics on division by 0. It checks some common/faster cases before fully committing to long division. This can probably be further optimized by implementing a successive approximation algorithm, with an initial seed value determined by a 64-bit division of the most significant bits.
func (Uint128) Int128 ¶
Int128 returns a Int128 representation of a Uint128
This function overflows silently
func (Uint128) Int64 ¶
Int64 returns a representation of the Uint128 as the builtin int64
This function overflows silently
func (Uint128) IsInt64 ¶
IsInt64 checks if the Uint128 can be represented as an int64 without overflowing
func (Uint128) IsUint64 ¶
IsUint64 checks if the Uint128 can be represented as a uint64 without overflowing
func (Uint128) Len ¶
Len returns the minimum number of bits required to represent x
Edge cases:
Uint128{0, 0}.Len() -> 0
func (Uint128) Mod ¶
Mod returns the remainder corresponding to the provided dividend and divisor
Mod panics on division by 0. It checks some common/faster cases before fully committing to long division. This can probably be further optimized by implementing a successive approximation algorithm, with an initial seed value determined by a 64-bit division of the most significant bits.
func (Uint128) Uint64 ¶
Uint64 returns a representation of the Uint128 as the builtin uint64
This function overflows silently