Documentation
¶
Overview ¶
Package currency implements the type PicoDollar and MicroDollar, and its conversions.
Index ¶
Constants ¶
View Source
const ( MicroDollarsPerDollar = 1e6 PicoDollarsPerDollar = 1e12 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MicroDollar ¶ added in v0.5.1
type MicroDollar int64
PicoDollar is a type to represent currency with 12 decimal precision
func (MicroDollar) ToBigInt ¶ added in v0.5.1
func (m MicroDollar) ToBigInt() *big.Int
type PicoDollar ¶
type PicoDollar int64
PicoDollar is a type to represent currency with 12 decimal precision
func FromDollars ¶
func FromDollars(dollars float64) (PicoDollar, error)
FromDollars converts a dollar amount (as a float) to Picodollars This should mostly be used for testing, and real usage should be done purely in PicoDollars
func FromMicrodollars ¶ added in v0.5.1
func FromMicrodollars(microdollars MicroDollar) PicoDollar
FromMicrodollars converts an int64 microdollar amount to PicoDollar
func (PicoDollar) String ¶
func (p PicoDollar) String() string
func (PicoDollar) ToDollars ¶ added in v1.0.0
func (p PicoDollar) ToDollars() float64
ToDollars converts PicoDollars to a dollar amount (as a float)
func (PicoDollar) ToMicroDollars ¶
func (p PicoDollar) ToMicroDollars() MicroDollar
ToMicroDollars converts PicoDollars to MicroDollars (1e6 units per dollar)
Click to show internal directories.
Click to hide internal directories.