Documentation ¶
Index ¶
- Variables
- func FloatFromPool() *big.Float
- type Decimal
- func (d Decimal) Abs() Decimal
- func (d Decimal) Add(addend Decimal) Decimal
- func (d Decimal) Cmp(other Decimal) int
- func (d Decimal) Div(denominator Decimal) Decimal
- func (d Decimal) EQ(other Decimal) bool
- func (d Decimal) Float() float64
- func (d Decimal) FormattedString(places int) string
- func (d Decimal) Frac(f float64) Decimal
- func (d Decimal) GT(other Decimal) bool
- func (d Decimal) GTE(other Decimal) bool
- func (d Decimal) IsZero() bool
- func (d Decimal) LT(other Decimal) bool
- func (d Decimal) LTE(other Decimal) bool
- func (d Decimal) MarshalJSON() ([]byte, error)
- func (d Decimal) Mul(factor Decimal) Decimal
- func (d Decimal) NaN() bool
- func (d Decimal) Neg() Decimal
- func (d Decimal) Pow(exp int) Decimal
- func (d Decimal) ReturnToPool()
- func (d *Decimal) Scan(src interface{}) error
- func (d Decimal) Sqrt() Decimal
- func (d Decimal) String() string
- func (d Decimal) Sub(subtrahend Decimal) Decimal
- func (d *Decimal) UnmarshalJSON(b []byte) error
- func (d Decimal) Value() (driver.Value, error)
- func (d Decimal) Zero() bool
Constants ¶
This section is empty.
Variables ¶
var ( // NaN == Not a Number NaN = NewDecimal(math.NaN()) // ZERO == 0 ZERO = NewFromString("0") // ONE == 1 ONE = NewFromString("1") // TEN == 10 TEN = NewFromString("10") // MarshalQuoted - can toggle this to true to marshal values as strings MarshalQuoted = false )
Functions ¶
func FloatFromPool ¶
Types ¶
type Decimal ¶
Decimal is the main exported type. It is a simple, immutable wrapper around a *big.Float
func DecimalFromPool ¶
func DecimalFromPool() Decimal
func NewDecimal ¶
NewDecimal creates a new Decimal type from a float value.
func NewFromInt ¶
NewFromInt creates a new Decimal type from an int value
func NewFromString ¶
NewFromString creates a new Decimal type from a string value.
func (Decimal) Cmp ¶
Cmp will return 1 if this decimal is greater than the provided, 0 if they are the same, and -1 if it is less.
func (Decimal) Float ¶
Float will return this Decimal as a float value. Note that there may be some loss of precision in this operation.
func (Decimal) FormattedString ¶
FormattedString returns the string value of the number to the requested precision
func (Decimal) Frac ¶
Frac returns another Decimal instance representing this Decimal multiplied by the provided float.
func (Decimal) GTE ¶
GTE returns true if this decimal is greater than or equal to the provided decimal.
func (Decimal) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (Decimal) ReturnToPool ¶
func (d Decimal) ReturnToPool()
func (*Decimal) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface