amount

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2020 License: ISC Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AtomsPerCent is the number of atomic units in one coin cent.
	// TODO, relocate the coin related item to chain's params
	AtomsPerCent = 1e6

	// AtomsPerCoin is the number of atomic units in one coin.
	// TODO, relocate the coin related item to chain's params
	AtomsPerCoin = 1e8

	// MaxAmount is the maximum transaction amount allowed in atoms.
	// TODO, relocate the coin related item to chain's params
	MaxAmount = 21e6 * AtomsPerCoin
)

Variables

This section is empty.

Functions

func NewAmount

func NewAmount(f float64) (uint64, error)

NewAmount creates an Amount from a floating point value representing some value in the currency. NewAmount errors if f is NaN or +-Infinity, but does not check that the amount is within the total amount of coins producible as f may not refer to an amount at a single moment in time.

NewAmount is for specifically for converting qitmeer to Atoms (atomic units). For creating a new Amount with an int64 value which denotes a quantity of Atoms, do a simple type conversion from type int64 to Amount.

Types

type Amount

type Amount int64

Amount represents the base coin monetary unit (colloquially referred to as an `Atom'). A single Amount is equal to 1e-8 of a coin.

func (Amount) ToCoin

func (a Amount) ToCoin() float64

ToCoin is the equivalent of calling ToUnit with AmountCoin.

func (Amount) ToUnit

func (a Amount) ToUnit(u AmountUnit) float64

ToUnit converts a monetary amount counted in coin base units to a floating point value representing an amount of coins.

type AmountUnit

type AmountUnit int

AmountUnit describes a method of converting an Amount to something other than the base unit of a coin. The value of the AmountUnit is the exponent component of the decadic multiple to convert from an amount in coins to an amount counted in atomic units.

const (
	AmountMegaCoin  AmountUnit = 6
	AmountKiloCoin  AmountUnit = 3
	AmountCoin      AmountUnit = 0
	AmountMilliCoin AmountUnit = -3
	AmountMicroCoin AmountUnit = -6
	AmountAtom      AmountUnit = -8
)

These constants define various units used when describing a coin monetary amount.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL