Documentation
¶
Index ¶
- func Add(d1 *inf.Dec, d2 *inf.Dec) *inf.Dec
- func Div(d1 *inf.Dec, d2 *inf.Dec, scale int) *inf.Dec
- func Mul(d1 *inf.Dec, d2 *inf.Dec) *inf.Dec
- func Round(d *inf.Dec, scale int) *inf.Dec
- func RoundUnit(d *inf.Dec, unit currency.Unit) *inf.Dec
- func Scale(s string) (int, error)
- func Sub(d1 *inf.Dec, d2 *inf.Dec) *inf.Dec
- func Unit(s string) (currency.Unit, error)
- func UnitDec(amt string, unit currency.Unit) *inf.Dec
- func UnitFmt(amt string, currency string) string
- func UnitScale(u currency.Unit) int
- type Amt
- func (a *Amt) Abs() *Amt
- func (a *Amt) Add(b *Amt) *Amt
- func (a *Amt) Cmp(b *Amt) int
- func (a *Amt) Div(b *Amt, scale int) *Amt
- func (a Amt) MarshalJSON() ([]byte, error)
- func (a *Amt) Mul(b *Amt) *Amt
- func (a *Amt) Round(scale int) *Amt
- func (a *Amt) RoundCurrency(currency string) (*Amt, error)
- func (a *Amt) RoundUnit(unit currency.Unit) *Amt
- func (et *Amt) Scan(value interface{}) error
- func (a *Amt) SetString(s string) error
- func (a *Amt) Sign() int
- func (a *Amt) String() string
- func (a *Amt) Sub(b *Amt) *Amt
- func (a *Amt) TryRoundCurrency(currency string) *Amt
- func (t *Amt) UnmarshalJSON(b []byte) error
- func (a Amt) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnitDec ¶
Create new signed arbitrary-precision decimal with appropriate scale for the currency and HalfEven rounding.
Types ¶
type Amt ¶
Amt represents arbitrary-precision decimal.
Amt is a type alias of inf.Dec. Amt can be used with encoding/json and gorm.
Different from inf.Dec, Amt always create new value for all math op (Add/Sub/Div/Mul) instead of setting the result back to the value itself.
Amt always use HalfEven rounding mode.
func (Amt) MarshalJSON ¶
Implements encoding/json Marshaler
func (*Amt) TryRoundCurrency ¶
func (*Amt) UnmarshalJSON ¶
Implements encoding/json Unmarshaler.
Click to show internal directories.
Click to hide internal directories.