Documentation
¶
Overview ¶
Package decimal implements arbitrary-precision decimal arithmetic.
Index ¶
- func Cmp(x, y Number) int
- func IsInt(x Number) bool
- func IsValid(x Number) bool
- type Fmt
- type Number
- func Abs(x Number) Number
- func Add(x, y Number) Number
- func Allocate(amount, unit Number, ratios ...uint) []Number
- func Ceil(x, unit Number) Number
- func Float64(f float64) Number
- func Floor(x, unit Number) Number
- func Int64(i int64) Number
- func Mul(x, y Number) Number
- func Neg(x Number) Number
- func Pow(x Number, n uint) Number
- func Prod(n ...Number) Number
- func Round(x, unit Number) Number
- func RoundToEven(x, unit Number) Number
- func Split(amount, unit Number, n uint) []Number
- func Sub(x, y Number) Number
- func Sum(n ...Number) Number
- func Trunc(x, unit Number) Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Number ¶
A Number is an arbitrary precision decimal number, stored as JSON text.
func Allocate ¶ added in v0.0.3
Allocate allocates an integer amount of units according to a list of ratios. Leftover units are distributed round-robin, from left to right.
func Round ¶ added in v0.0.3
Round rounds x to the nearest multiple of unit, with ties away from zero.
func RoundToEven ¶ added in v0.0.3
RoundToEven rounds x to the nearest multiple of unit, with ties to an even multiple of unit.
Click to show internal directories.
Click to hide internal directories.