Documentation
¶
Overview ¶
Package decimal is an exact base-10 number for money and quantities.
A Decimal is an integer coefficient over a power of ten, so addition and multiplication never round. Scale limits are the caller's to enforce.
Index ¶
- type Decimal
- func (d Decimal) Add(other Decimal) Decimal
- func (d Decimal) Cmp(other Decimal) int
- func (d Decimal) DivPow10(power int) Decimal
- func (d Decimal) MarshalJSON() ([]byte, error)
- func (d Decimal) Mul(other Decimal) Decimal
- func (d Decimal) Scale() int
- func (d Decimal) Sign() int
- func (d Decimal) String() string
- func (d Decimal) Sub(other Decimal) Decimal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
Decimal is an exact non-negative or negative decimal value. The zero value is 0.
func ParseNumber ¶
ParseNumber reads a figure another program wrote as a JSON number, exactly. Unlike Parse it takes a leading minus and an exponent, as in -0.25 or 1.2e-05, because a provider's report or a gateway's float can carry either.
func (Decimal) MarshalJSON ¶
MarshalJSON writes the value as a JSON string, never a JSON number.