Documentation
¶
Overview ¶
Package bigdecimal extends decimal128 with canonical presentation and Money. Native arithmetic and rounding semantics are preserved, including special values.
Code generated by internal/gendecimal; DO NOT EDIT.
Index ¶
- Constants
- Variables
- func Compare(d Decimal, o Decimal) int
- type CmpResult
- type Decimal
- func Abs(d Decimal) Decimal
- func Cbrt(d Decimal) Decimal
- func Ceil(d Decimal) Decimal
- func E() Decimal
- func Exp(d Decimal) Decimal
- func Exp2(d Decimal) Decimal
- func Exp10(d Decimal) Decimal
- func Expm1(d Decimal) Decimal
- func Floor(d Decimal) Decimal
- func Frexp(d Decimal) (Decimal, int)
- func FromFloat(f *big.Float) Decimal
- func FromFloat32(f float32) Decimal
- func FromFloat64(f float64) Decimal
- func FromInt(i *big.Int) Decimal
- func FromInt32(i int32) Decimal
- func FromInt64(i int64) Decimal
- func FromRat(r *big.Rat) Decimal
- func FromUint32(i uint32) Decimal
- func FromUint64(i uint64) Decimal
- func Inf(sign int) Decimal
- func Ldexp(frac Decimal, exp int) Decimal
- func Log(d Decimal) Decimal
- func Log1p(d Decimal) Decimal
- func Log2(d Decimal) Decimal
- func Log10(d Decimal) Decimal
- func Max(d Decimal, o Decimal) Decimal
- func Min(d Decimal, o Decimal) Decimal
- func MustParse(s string) Decimal
- func NaN() Decimal
- func New(sig int64, exp int) Decimal
- func Parse(s string) (Decimal, error)
- func Phi() Decimal
- func Pi() Decimal
- func Round(d Decimal) Decimal
- func Sqrt(d Decimal) Decimal
- func Trunc(d Decimal) Decimal
- func (d Decimal) Add(o Decimal) Decimal
- func (d Decimal) AddWithMode(o Decimal, mode RoundingMode) Decimal
- func (d Decimal) AppendText(dst []byte) ([]byte, error)
- func (d Decimal) Canonical() Decimal
- func (d Decimal) Ceil(dp int) Decimal
- func (d Decimal) Cmp(o Decimal) CmpResult
- func (d Decimal) CmpAbs(o Decimal) CmpResult
- func (d Decimal) Compare(other Decimal) int
- func (d Decimal) Decompose(buf []byte) (byte, bool, []byte, int32)
- func (d Decimal) Equal(o Decimal) bool
- func (d Decimal) Float(f *big.Float) *big.Float
- func (d Decimal) Float32() float32
- func (d Decimal) Float64() float64
- func (d Decimal) Floor(dp int) Decimal
- func (d Decimal) Format(state fmt.State, verb rune)
- func (d Decimal) Int(i *big.Int) *big.Int
- func (d Decimal) Int32() (int32, bool)
- func (d Decimal) Int64() (int64, bool)
- func (d Decimal) IsInf(sign int) bool
- func (d Decimal) IsNaN() bool
- func (d Decimal) IsZero() bool
- func (d Decimal) MarshalJSON() ([]byte, error)
- func (d Decimal) MarshalText() ([]byte, error)
- func (d Decimal) Mul(o Decimal) Decimal
- func (d Decimal) MulWithMode(o Decimal, mode RoundingMode) Decimal
- func (d Decimal) Neg() Decimal
- func (d Decimal) Payload() Payload
- func (d Decimal) Pow(o Decimal) Decimal
- func (d Decimal) PowWithMode(o Decimal, mode RoundingMode) Decimal
- func (d Decimal) Quo(o Decimal) Decimal
- func (d Decimal) QuoRem(o Decimal) (Decimal, Decimal)
- func (d Decimal) QuoRemWithMode(o Decimal, mode RoundingMode) (Decimal, Decimal)
- func (d Decimal) QuoWithMode(o Decimal, mode RoundingMode) Decimal
- func (d Decimal) Rat(r *big.Rat) *big.Rat
- func (d Decimal) Round(dp int, mode RoundingMode) Decimal
- func (d Decimal) Sign() int
- func (d Decimal) Signbit() bool
- func (d Decimal) String() string
- func (d Decimal) Sub(o Decimal) Decimal
- func (d Decimal) SubWithMode(o Decimal, mode RoundingMode) Decimal
- func (d Decimal) Uint32() (uint32, bool)
- func (d Decimal) Uint64() (uint64, bool)
- func (d *Decimal) UnmarshalJSON(data []byte) error
- func (d *Decimal) UnmarshalText(data []byte) error
- type Money
- type MoneyOptions
- type Payload
- type RoundingMode
Constants ¶
View Source
const ( ToNearestEven = upstream.ToNearestEven ToNearestAway = upstream.ToNearestAway ToZero = upstream.ToZero AwayFromZero = upstream.AwayFromZero ToNegativeInf = upstream.ToNegativeInf ToPositiveInf = upstream.ToPositiveInf )
Variables ¶
View Source
var One = FromInt64(1)
View Source
var Zero = Decimal{}
Functions ¶
Types ¶
type Decimal ¶
func FromFloat32 ¶
func FromFloat64 ¶
func FromUint32 ¶
func FromUint64 ¶
func (Decimal) AddWithMode ¶
func (d Decimal) AddWithMode(o Decimal, mode RoundingMode) Decimal
func (Decimal) Compare ¶
Compare returns -1, 0 or 1 as d is less than, equal to or greater than other, using the upstream total order: NaN is less than every other value and equal to NaN.
func (Decimal) MarshalJSON ¶
func (Decimal) MarshalText ¶
func (Decimal) MulWithMode ¶
func (d Decimal) MulWithMode(o Decimal, mode RoundingMode) Decimal
func (Decimal) PowWithMode ¶
func (d Decimal) PowWithMode(o Decimal, mode RoundingMode) Decimal
func (Decimal) QuoRemWithMode ¶
func (d Decimal) QuoRemWithMode(o Decimal, mode RoundingMode) (Decimal, Decimal)
func (Decimal) QuoWithMode ¶
func (d Decimal) QuoWithMode(o Decimal, mode RoundingMode) Decimal
func (Decimal) SubWithMode ¶
func (d Decimal) SubWithMode(o Decimal, mode RoundingMode) Decimal
func (*Decimal) UnmarshalJSON ¶
func (*Decimal) UnmarshalText ¶
type Money ¶
func NewMoney ¶
func NewMoney(opts MoneyOptions) (Money, error)
func (Money) Add ¶
Add sums amounts in the same currency; the result keeps the wider display places.
type MoneyOptions ¶
type RoundingMode ¶
type RoundingMode = upstream.RoundingMode
Click to show internal directories.
Click to hide internal directories.