Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Error wraps errors coming from this package. Error = errs.Class("currency") )
Functions ¶
This section is empty.
Types ¶
type MicroUnit ¶ added in v1.1.1
type MicroUnit struct {
// contains filtered or unexported fields
}
MicroUnit represents 1e-6 or one millionth of a unit of currency (e.g. one millionth of a dollar). It is used instead of a floating point type to prevent rounding errors.
var ( // Zero is a MicroUnit representing 0. Zero MicroUnit )
func MicroUnitFromDecimal ¶ added in v1.1.1
MicroUnitFromDecimal returns a MicroUnit from a decimal value and returns an error if there is not enough precision.
func MicroUnitFromFloatString ¶ added in v1.1.1
MicroUnitFromFloatString parses the string from FloatString into a MicroUnit.
func NewMicroUnit ¶ added in v1.1.1
NewMicroUnit returns a MicroUnit with v. Much like a time.Duration, a value of 1 means 1e-6 or one millionth of a unit of currency.
func (MicroUnit) FloatString ¶ added in v1.1.1
FloatString returns a string fixed to 6 decimal places.
func (MicroUnit) MarshalCSV ¶ added in v1.1.1
MarshalCSV does the custom marshaling of MicroUnits.
func (*MicroUnit) UnmarshalCSV ¶ added in v1.1.1
UnmarshalCSV reads the MicroUnit in CSV form.