package big

Import Path
	math/big (on golang.org and go.dev)

Dependency Relation
	imports 12 packages, and imported by 11 packages

Involved Source Files
	    accuracy_string.go
	    arith.go
	    arith_amd64.go
	    arith_decl.go
	    decimal.go
	d-> doc.go
	    float.go
	    floatconv.go
	    floatmarsh.go
	    ftoa.go
	    int.go
	    intconv.go
	    intmarsh.go
	    nat.go
	    natconv.go
	    prime.go
	    rat.go
	    ratconv.go
	    ratmarsh.go
	    roundingmode_string.go
	    sqrt.go
	    arith_amd64.s

Exported Type Names

type Accuracy int8 Accuracy describes the rounding error produced by the most recent operation that generated a Float value, relative to the exact value. (T) String() string T : fmt.Stringer func (*Float).Acc() Accuracy func (*Float).Float32() (float32, Accuracy) func (*Float).Float64() (float64, Accuracy) func (*Float).Int(z *Int) (*Int, Accuracy) func (*Float).Int64() (int64, Accuracy) func (*Float).Rat(z *Rat) (*Rat, Accuracy) func (*Float).Uint64() (uint64, Accuracy) const Above const Below const Exact
type ErrNaN (struct) An ErrNaN panic is raised by a Float operation that would lead to a NaN under IEEE-754 rules. An ErrNaN implements the error interface. (T) Error() string T : error
type Float (struct) A nonzero finite Float represents a multi-precision floating point number sign × mantissa × 2**exponent with 0.5 <= mantissa < 1.0, and MinExp <= exponent <= MaxExp. A Float may also be zero (+0, -0) or infinite (+Inf, -Inf). All Floats are ordered, and the ordering of two Floats x and y is defined by x.Cmp(y). Each Float value also has a precision, rounding mode, and accuracy. The precision is the maximum number of mantissa bits available to represent the value. The rounding mode specifies how a result should be rounded to fit into the mantissa bits, and accuracy describes the rounding error with respect to the exact result. Unless specified otherwise, all operations (including setters) that specify a *Float variable for the result (usually via the receiver with the exception of MantExp), round the numeric result according to the precision and rounding mode of the result variable. If the provided result precision is 0 (see below), it is set to the precision of the argument with the largest precision value before any rounding takes place, and the rounding mode remains unchanged. Thus, uninitialized Floats provided as result arguments will have their precision set to a reasonable value determined by the operands, and their mode is the zero value for RoundingMode (ToNearestEven). By setting the desired precision to 24 or 53 and using matching rounding mode (typically ToNearestEven), Float operations produce the same results as the corresponding float32 or float64 IEEE-754 arithmetic for operands that correspond to normal (i.e., not denormal) float32 or float64 numbers. Exponent underflow and overflow lead to a 0 or an Infinity for different values than IEEE-754 because Float exponents have a much larger range. The zero (uninitialized) value for a Float is ready to use and represents the number +0.0 exactly, with precision 0 and rounding mode ToNearestEven. Operations always take pointer arguments (*Float) rather than Float values, and each unique Float value requires its own unique *Float pointer. To "copy" a Float value, an existing (or newly allocated) Float must be set to a new value using the Float.Set method; shallow copies of Floats are not supported and may lead to errors. (*T) Abs(x *Float) *Float (*T) Acc() Accuracy (*T) Add(x, y *Float) *Float (*T) Append(buf []byte, fmt byte, prec int) []byte (*T) Cmp(y *Float) int (*T) Copy(x *Float) *Float (*T) Float32() (float32, Accuracy) (*T) Float64() (float64, Accuracy) (*T) Format(s fmt.State, format rune) (*T) GobDecode(buf []byte) error (*T) GobEncode() ([]byte, error) (*T) Int(z *Int) (*Int, Accuracy) (*T) Int64() (int64, Accuracy) (*T) IsInf() bool (*T) IsInt() bool (*T) MantExp(mant *Float) (exp int) (*T) MarshalText() (text []byte, err error) (*T) MinPrec() uint (*T) Mode() RoundingMode (*T) Mul(x, y *Float) *Float (*T) Neg(x *Float) *Float (*T) Parse(s string, base int) (f *Float, b int, err error) (*T) Prec() uint (*T) Quo(x, y *Float) *Float (*T) Rat(z *Rat) (*Rat, Accuracy) (*T) Scan(s fmt.ScanState, ch rune) error (*T) Set(x *Float) *Float (*T) SetFloat64(x float64) *Float (*T) SetInf(signbit bool) *Float (*T) SetInt(x *Int) *Float (*T) SetInt64(x int64) *Float (*T) SetMantExp(mant *Float, exp int) *Float (*T) SetMode(mode RoundingMode) *Float (*T) SetPrec(prec uint) *Float (*T) SetRat(x *Rat) *Float (*T) SetString(s string) (*Float, bool) (*T) SetUint64(x uint64) *Float (*T) Sign() int (*T) Signbit() bool (*T) Sqrt(x *Float) *Float (*T) String() string (*T) Sub(x, y *Float) *Float (*T) Text(format byte, prec int) string (*T) Uint64() (uint64, Accuracy) (*T) UnmarshalText(text []byte) error *T : encoding.TextMarshaler *T : encoding.TextUnmarshaler *T : fmt.Formatter *T : fmt.Scanner *T : fmt.Stringer func NewFloat(x float64) *Float func ParseFloat(s string, base int, prec uint, mode RoundingMode) (f *Float, b int, err error) func (*Float).Abs(x *Float) *Float func (*Float).Add(x, y *Float) *Float func (*Float).Copy(x *Float) *Float func (*Float).Mul(x, y *Float) *Float func (*Float).Neg(x *Float) *Float func (*Float).Parse(s string, base int) (f *Float, b int, err error) func (*Float).Quo(x, y *Float) *Float func (*Float).Set(x *Float) *Float func (*Float).SetFloat64(x float64) *Float func (*Float).SetInf(signbit bool) *Float func (*Float).SetInt(x *Int) *Float func (*Float).SetInt64(x int64) *Float func (*Float).SetMantExp(mant *Float, exp int) *Float func (*Float).SetMode(mode RoundingMode) *Float func (*Float).SetPrec(prec uint) *Float func (*Float).SetRat(x *Rat) *Float func (*Float).SetString(s string) (*Float, bool) func (*Float).SetUint64(x uint64) *Float func (*Float).Sqrt(x *Float) *Float func (*Float).Sub(x, y *Float) *Float func (*Float).Abs(x *Float) *Float func (*Float).Add(x, y *Float) *Float func (*Float).Cmp(y *Float) int func (*Float).Copy(x *Float) *Float func (*Float).MantExp(mant *Float) (exp int) func (*Float).Mul(x, y *Float) *Float func (*Float).Neg(x *Float) *Float func (*Float).Quo(x, y *Float) *Float func (*Float).Set(x *Float) *Float func (*Float).SetMantExp(mant *Float, exp int) *Float func (*Float).Sqrt(x *Float) *Float func (*Float).Sub(x, y *Float) *Float
type Int (struct) An Int represents a signed multi-precision integer. The zero value for an Int represents the value 0. Operations always take pointer arguments (*Int) rather than Int values, and each unique Int value requires its own unique *Int pointer. To "copy" an Int value, an existing (or newly allocated) Int must be set to a new value using the Int.Set method; shallow copies of Ints are not supported and may lead to errors. (*T) Abs(x *Int) *Int (*T) Add(x, y *Int) *Int (*T) And(x, y *Int) *Int (*T) AndNot(x, y *Int) *Int (*T) Append(buf []byte, base int) []byte (*T) Binomial(n, k int64) *Int (*T) Bit(i int) uint (*T) BitLen() int (*T) Bits() []Word (*T) Bytes() []byte (*T) Cmp(y *Int) (r int) (*T) CmpAbs(y *Int) int (*T) Div(x, y *Int) *Int (*T) DivMod(x, y, m *Int) (*Int, *Int) (*T) Exp(x, y, m *Int) *Int (*T) FillBytes(buf []byte) []byte (*T) Format(s fmt.State, ch rune) (*T) GCD(x, y, a, b *Int) *Int (*T) GobDecode(buf []byte) error (*T) GobEncode() ([]byte, error) (*T) Int64() int64 (*T) IsInt64() bool (*T) IsUint64() bool (*T) Lsh(x *Int, n uint) *Int (*T) MarshalJSON() ([]byte, error) (*T) MarshalText() (text []byte, err error) (*T) Mod(x, y *Int) *Int (*T) ModInverse(g, n *Int) *Int (*T) ModSqrt(x, p *Int) *Int (*T) Mul(x, y *Int) *Int (*T) MulRange(a, b int64) *Int (*T) Neg(x *Int) *Int (*T) Not(x *Int) *Int (*T) Or(x, y *Int) *Int (*T) ProbablyPrime(n int) bool (*T) Quo(x, y *Int) *Int (*T) QuoRem(x, y, r *Int) (*Int, *Int) (*T) Rand(rnd *rand.Rand, n *Int) *Int (*T) Rem(x, y *Int) *Int (*T) Rsh(x *Int, n uint) *Int (*T) Scan(s fmt.ScanState, ch rune) error (*T) Set(x *Int) *Int (*T) SetBit(x *Int, i int, b uint) *Int (*T) SetBits(abs []Word) *Int (*T) SetBytes(buf []byte) *Int (*T) SetInt64(x int64) *Int (*T) SetString(s string, base int) (*Int, bool) (*T) SetUint64(x uint64) *Int (*T) Sign() int (*T) Sqrt(x *Int) *Int (*T) String() string (*T) Sub(x, y *Int) *Int (*T) Text(base int) string (*T) TrailingZeroBits() uint (*T) Uint64() uint64 (*T) UnmarshalJSON(text []byte) error (*T) UnmarshalText(text []byte) error (*T) Xor(x, y *Int) *Int *T : encoding.TextMarshaler *T : encoding.TextUnmarshaler *T : encoding/json.Marshaler *T : encoding/json.Unmarshaler *T : fmt.Formatter *T : fmt.Scanner *T : fmt.Stringer func NewInt(x int64) *Int func (*Float).Int(z *Int) (*Int, Accuracy) func (*Int).Abs(x *Int) *Int func (*Int).Add(x, y *Int) *Int func (*Int).And(x, y *Int) *Int func (*Int).AndNot(x, y *Int) *Int func (*Int).Binomial(n, k int64) *Int func (*Int).Div(x, y *Int) *Int func (*Int).DivMod(x, y, m *Int) (*Int, *Int) func (*Int).DivMod(x, y, m *Int) (*Int, *Int) func (*Int).Exp(x, y, m *Int) *Int func (*Int).GCD(x, y, a, b *Int) *Int func (*Int).Lsh(x *Int, n uint) *Int func (*Int).Mod(x, y *Int) *Int func (*Int).ModInverse(g, n *Int) *Int func (*Int).ModSqrt(x, p *Int) *Int func (*Int).Mul(x, y *Int) *Int func (*Int).MulRange(a, b int64) *Int func (*Int).Neg(x *Int) *Int func (*Int).Not(x *Int) *Int func (*Int).Or(x, y *Int) *Int func (*Int).Quo(x, y *Int) *Int func (*Int).QuoRem(x, y, r *Int) (*Int, *Int) func (*Int).QuoRem(x, y, r *Int) (*Int, *Int) func (*Int).Rand(rnd *rand.Rand, n *Int) *Int func (*Int).Rem(x, y *Int) *Int func (*Int).Rsh(x *Int, n uint) *Int func (*Int).Set(x *Int) *Int func (*Int).SetBit(x *Int, i int, b uint) *Int func (*Int).SetBits(abs []Word) *Int func (*Int).SetBytes(buf []byte) *Int func (*Int).SetInt64(x int64) *Int func (*Int).SetString(s string, base int) (*Int, bool) func (*Int).SetUint64(x uint64) *Int func (*Int).Sqrt(x *Int) *Int func (*Int).Sub(x, y *Int) *Int func (*Int).Xor(x, y *Int) *Int func (*Rat).Denom() *Int func (*Rat).Num() *Int func crypto/dsa.Sign(rand io.Reader, priv *dsa.PrivateKey, hash []byte) (r, s *Int, err error) func crypto/ecdsa.Sign(rand io.Reader, priv *ecdsa.PrivateKey, hash []byte) (r, s *Int, err error) func crypto/elliptic.GenerateKey(curve elliptic.Curve, rand io.Reader) (priv []byte, x, y *Int, err error) func crypto/elliptic.Unmarshal(curve elliptic.Curve, data []byte) (x, y *Int) func crypto/elliptic.UnmarshalCompressed(curve elliptic.Curve, data []byte) (x, y *Int) func crypto/elliptic.Curve.Add(x1, y1, x2, y2 *Int) (x, y *Int) func crypto/elliptic.Curve.Double(x1, y1 *Int) (x, y *Int) func crypto/elliptic.Curve.ScalarBaseMult(k []byte) (x, y *Int) func crypto/elliptic.Curve.ScalarMult(x1, y1 *Int, k []byte) (x, y *Int) func crypto/elliptic.(*CurveParams).Add(x1, y1, x2, y2 *Int) (*Int, *Int) func crypto/elliptic.(*CurveParams).Add(x1, y1, x2, y2 *Int) (*Int, *Int) func crypto/elliptic.(*CurveParams).Double(x1, y1 *Int) (*Int, *Int) func crypto/elliptic.(*CurveParams).Double(x1, y1 *Int) (*Int, *Int) func crypto/elliptic.(*CurveParams).ScalarBaseMult(k []byte) (*Int, *Int) func crypto/elliptic.(*CurveParams).ScalarBaseMult(k []byte) (*Int, *Int) func crypto/elliptic.(*CurveParams).ScalarMult(Bx, By *Int, k []byte) (*Int, *Int) func crypto/elliptic.(*CurveParams).ScalarMult(Bx, By *Int, k []byte) (*Int, *Int) func crypto/rand.Int(rand io.Reader, max *Int) (n *Int, err error) func crypto/rand.Prime(rand io.Reader, bits int) (p *Int, err error) func Jacobi(x, y *Int) int func (*Float).Int(z *Int) (*Int, Accuracy) func (*Float).SetInt(x *Int) *Float func (*Int).Abs(x *Int) *Int func (*Int).Add(x, y *Int) *Int func (*Int).And(x, y *Int) *Int func (*Int).AndNot(x, y *Int) *Int func (*Int).Cmp(y *Int) (r int) func (*Int).CmpAbs(y *Int) int func (*Int).Div(x, y *Int) *Int func (*Int).DivMod(x, y, m *Int) (*Int, *Int) func (*Int).Exp(x, y, m *Int) *Int func (*Int).GCD(x, y, a, b *Int) *Int func (*Int).Lsh(x *Int, n uint) *Int func (*Int).Mod(x, y *Int) *Int func (*Int).ModInverse(g, n *Int) *Int func (*Int).ModSqrt(x, p *Int) *Int func (*Int).Mul(x, y *Int) *Int func (*Int).Neg(x *Int) *Int func (*Int).Not(x *Int) *Int func (*Int).Or(x, y *Int) *Int func (*Int).Quo(x, y *Int) *Int func (*Int).QuoRem(x, y, r *Int) (*Int, *Int) func (*Int).Rand(rnd *rand.Rand, n *Int) *Int func (*Int).Rem(x, y *Int) *Int func (*Int).Rsh(x *Int, n uint) *Int func (*Int).Set(x *Int) *Int func (*Int).SetBit(x *Int, i int, b uint) *Int func (*Int).Sqrt(x *Int) *Int func (*Int).Sub(x, y *Int) *Int func (*Int).Xor(x, y *Int) *Int func (*Rat).SetFrac(a, b *Int) *Rat func (*Rat).SetInt(x *Int) *Rat func crypto/dsa.Verify(pub *dsa.PublicKey, hash []byte, r, s *Int) bool func crypto/ecdsa.Verify(pub *ecdsa.PublicKey, hash []byte, r, s *Int) bool func crypto/elliptic.Marshal(curve elliptic.Curve, x, y *Int) []byte func crypto/elliptic.MarshalCompressed(curve elliptic.Curve, x, y *Int) []byte func crypto/elliptic.Curve.Add(x1, y1, x2, y2 *Int) (x, y *Int) func crypto/elliptic.Curve.Double(x1, y1 *Int) (x, y *Int) func crypto/elliptic.Curve.IsOnCurve(x, y *Int) bool func crypto/elliptic.Curve.ScalarMult(x1, y1 *Int, k []byte) (x, y *Int) func crypto/elliptic.(*CurveParams).Add(x1, y1, x2, y2 *Int) (*Int, *Int) func crypto/elliptic.(*CurveParams).Double(x1, y1 *Int) (*Int, *Int) func crypto/elliptic.(*CurveParams).IsOnCurve(x, y *Int) bool func crypto/elliptic.(*CurveParams).ScalarMult(Bx, By *Int, k []byte) (*Int, *Int) func crypto/rand.Int(rand io.Reader, max *Int) (n *Int, err error) func vendor/golang.org/x/crypto/cryptobyte.(*Builder).AddASN1BigInt(n *Int)
type Rat (struct) A Rat represents a quotient a/b of arbitrary precision. The zero value for a Rat represents the value 0. Operations always take pointer arguments (*Rat) rather than Rat values, and each unique Rat value requires its own unique *Rat pointer. To "copy" a Rat value, an existing (or newly allocated) Rat must be set to a new value using the Rat.Set method; shallow copies of Rats are not supported and may lead to errors. (*T) Abs(x *Rat) *Rat (*T) Add(x, y *Rat) *Rat (*T) Cmp(y *Rat) int (*T) Denom() *Int (*T) Float32() (f float32, exact bool) (*T) Float64() (f float64, exact bool) (*T) FloatString(prec int) string (*T) GobDecode(buf []byte) error (*T) GobEncode() ([]byte, error) (*T) Inv(x *Rat) *Rat (*T) IsInt() bool (*T) MarshalText() (text []byte, err error) (*T) Mul(x, y *Rat) *Rat (*T) Neg(x *Rat) *Rat (*T) Num() *Int (*T) Quo(x, y *Rat) *Rat (*T) RatString() string (*T) Scan(s fmt.ScanState, ch rune) error (*T) Set(x *Rat) *Rat (*T) SetFloat64(f float64) *Rat (*T) SetFrac(a, b *Int) *Rat (*T) SetFrac64(a, b int64) *Rat (*T) SetInt(x *Int) *Rat (*T) SetInt64(x int64) *Rat (*T) SetString(s string) (*Rat, bool) (*T) SetUint64(x uint64) *Rat (*T) Sign() int (*T) String() string (*T) Sub(x, y *Rat) *Rat (*T) UnmarshalText(text []byte) error *T : encoding.TextMarshaler *T : encoding.TextUnmarshaler *T : fmt.Scanner *T : fmt.Stringer func NewRat(a, b int64) *Rat func (*Float).Rat(z *Rat) (*Rat, Accuracy) func (*Rat).Abs(x *Rat) *Rat func (*Rat).Add(x, y *Rat) *Rat func (*Rat).Inv(x *Rat) *Rat func (*Rat).Mul(x, y *Rat) *Rat func (*Rat).Neg(x *Rat) *Rat func (*Rat).Quo(x, y *Rat) *Rat func (*Rat).Set(x *Rat) *Rat func (*Rat).SetFloat64(f float64) *Rat func (*Rat).SetFrac(a, b *Int) *Rat func (*Rat).SetFrac64(a, b int64) *Rat func (*Rat).SetInt(x *Int) *Rat func (*Rat).SetInt64(x int64) *Rat func (*Rat).SetString(s string) (*Rat, bool) func (*Rat).SetUint64(x uint64) *Rat func (*Rat).Sub(x, y *Rat) *Rat func (*Float).Rat(z *Rat) (*Rat, Accuracy) func (*Float).SetRat(x *Rat) *Float func (*Rat).Abs(x *Rat) *Rat func (*Rat).Add(x, y *Rat) *Rat func (*Rat).Cmp(y *Rat) int func (*Rat).Inv(x *Rat) *Rat func (*Rat).Mul(x, y *Rat) *Rat func (*Rat).Neg(x *Rat) *Rat func (*Rat).Quo(x, y *Rat) *Rat func (*Rat).Set(x *Rat) *Rat func (*Rat).Sub(x, y *Rat) *Rat
type RoundingMode byte RoundingMode determines how a Float value is rounded to the desired precision. Rounding may change the Float value; the rounding error is described by the Float's Accuracy. (T) String() string T : fmt.Stringer func (*Float).Mode() RoundingMode func ParseFloat(s string, base int, prec uint, mode RoundingMode) (f *Float, b int, err error) func (*Float).SetMode(mode RoundingMode) *Float const AwayFromZero const ToNearestAway const ToNearestEven const ToNegativeInf const ToPositiveInf const ToZero
type Word uint A Word represents a single digit of a multi-precision unsigned integer. func (*Int).Bits() []Word func (*Int).SetBits(abs []Word) *Int
Exported Values
const Above Accuracy = 1 Constants describing the Accuracy of a Float.
const AwayFromZero RoundingMode = 3 // no IEEE 754-2008 equivalent These constants define supported rounding modes.
const Below Accuracy = -1 Constants describing the Accuracy of a Float.
const Exact Accuracy = 0 Constants describing the Accuracy of a Float.
func Jacobi(x, y *Int) int Jacobi returns the Jacobi symbol (x/y), either +1, -1, or 0. The y argument must be an odd integer.
const MaxBase = 62 MaxBase is the largest number base accepted for string conversions.
const MaxExp = 2147483647 // largest supported exponent Exponent and precision limits.
const MaxPrec = 4294967295 // largest (theoretically) supported precision; likely memory-limited Exponent and precision limits.
const MinExp = -2147483648 // smallest supported exponent Exponent and precision limits.
func NewFloat(x float64) *Float NewFloat allocates and returns a new Float set to x, with precision 53 and rounding mode ToNearestEven. NewFloat panics with ErrNaN if x is a NaN.
func NewInt(x int64) *Int NewInt allocates and returns a new Int set to x.
func NewRat(a, b int64) *Rat NewRat creates a new Rat with numerator a and denominator b.
func ParseFloat(s string, base int, prec uint, mode RoundingMode) (f *Float, b int, err error) ParseFloat is like f.Parse(s, base) with f set to the given precision and rounding mode.
const ToNearestAway RoundingMode = 1 // == IEEE 754-2008 roundTiesToAway These constants define supported rounding modes.
const ToNearestEven RoundingMode = 0 // == IEEE 754-2008 roundTiesToEven These constants define supported rounding modes.
const ToNegativeInf RoundingMode = 4 // == IEEE 754-2008 roundTowardNegative These constants define supported rounding modes.
const ToPositiveInf RoundingMode = 5 // == IEEE 754-2008 roundTowardPositive These constants define supported rounding modes.
const ToZero RoundingMode = 2 // == IEEE 754-2008 roundTowardZero These constants define supported rounding modes.