Documentation
¶
Index ¶
- Constants
- func BankersRound(value *big.Int, scale *big.Int) *big.Int
- type Decimal
- func (d *Decimal) Abs() *Decimal
- func (x *Decimal) Add(y *Decimal) *Decimal
- func (x *Decimal) Cmp(y *Decimal) int
- func (d *Decimal) Copy() *Decimal
- func (x *Decimal) Div(y *Decimal) *Decimal
- func (d *Decimal) Float64() float64
- func (d *Decimal) GetIncrement() int64
- func (d *Decimal) GetScale() int64
- func (d *Decimal) GetSmallestIncrement() *Decimal
- func (d *Decimal) Int64() int64
- func (d *Decimal) MarshalJSON() ([]byte, error)
- func (x *Decimal) Mul(y *Decimal) *Decimal
- func (d *Decimal) OffsetPercent(o *Decimal) *Decimal
- func (d *Decimal) OffsetTicks(o *Decimal) *Decimal
- func (x *Decimal) Pow(y *Decimal) *Decimal
- func (d *Decimal) Rat() *big.Rat
- func (d *Decimal) RawBigInt() *big.Int
- func (d *Decimal) ScalingFactor() *big.Int
- func (d *Decimal) SetIncrement(increment int64) *Decimal
- func (d *Decimal) SetRounding(rounding RoundingFunction) *Decimal
- func (d *Decimal) SetScale(scale int64) *Decimal
- func (d *Decimal) SetSize(size *Decimal) *Decimal
- func (d *Decimal) Sign() int
- func (d *Decimal) String() string
- func (x *Decimal) Sub(y *Decimal) *Decimal
- func (d *Decimal) UnmarshalJSON(data []byte) error
- type RoundingFunction
Constants ¶
const DefaultIncrement = 1
Default increment for integer constructors.
const DefaultScale = 12
Default decimal points set for integer constructors.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
Decimal implements fixed-point arithmetic.
func NewFromBigFloat ¶
NewFromBigFloat creates a new Decimal object from a big.Float.
func NewFromBigInt ¶
func NewFromFloat64 ¶
NewFromFloat64 creates a new Decimal object from a float64.
func NewFromInt64 ¶
NewFromInt64 creates a new Decimal object from an int64.
func NewFromString ¶
NewFromString creates a new Decimal object from a string.
func (*Decimal) Float64 ¶
Float64 returns the floating point representation of m with potential loss of precision.
func (*Decimal) GetIncrement ¶
GetIncrement returns the smallest allowable unit for the decimal value.
func (*Decimal) GetSmallestIncrement ¶
GetSmallestIncrement returns the smallest possible increment of d.
func (*Decimal) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Decimal) OffsetPercent ¶
OffsetPercent returns the adjustment of d by %o. Formula: m * (1 + o). The multiplicand decimals are set to the max precision of both d and o.
func (*Decimal) OffsetTicks ¶
OffsetTicks returns the adjustment of m by an increment proportional to o.
func (*Decimal) RawBigInt ¶
RawBigInt returns the raw integer representation in the form of big.Int.
func (*Decimal) ScalingFactor ¶
ScalingFactor returns 10 ^ decimals in big.Int.
func (*Decimal) SetIncrement ¶
SetIncrement sets the smallest allowable unit of d.
func (*Decimal) SetRounding ¶
func (d *Decimal) SetRounding(rounding RoundingFunction) *Decimal
func (*Decimal) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.