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
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.
The pages are generated with Goldsv0.1.6. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project and developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.