Documentation ¶
Index ¶
- Constants
- Variables
- type Coin
- func AddCoin(c, b Coin) (Coin, error)
- func AddInt64(c Coin, a int64) (Coin, error)
- func DistributeCoin(c Coin, a int64) (oCur, bal Coin, err error)
- func Float64ToCoin(a float64) (Coin, error)
- func Int64ToCoin(a int64) (Coin, error)
- func Min(a, b Coin) (c Coin)
- func MinusCoin(c, b Coin) (Coin, error)
- func MinusInt64(c Coin, a int64) (Coin, error)
- func MultCoin(c, b Coin) (Coin, error)
- func MultFloat64(c Coin, a float64) (Coin, error)
- func ParseZCN(c float64) (Coin, error)
Constants ¶
const ( ZCN = 1e10 MZCN = 1e7 UZCN = 1e4 ZCNExponent = 10 MZCNExponent = 7 UZCNExponent = 4 )
Variables ¶
var ( // ErrNegativeValue is returned if a float value is a negative number ErrNegativeValue = errors.New("negative coin value") // ErrTooManyDecimals is returned if a value has more than 10 decimal places ErrTooManyDecimals = errors.New("too many decimal places") // ErrTooLarge is returned if a value is greater than math.MaxInt64 ErrTooLarge = errors.New("value is too large") // ErrUint64MultOverflow is returned if when multiplying uint64 values overflow uint64 ErrUint64MultOverflow = errors.New("uint64 multiplication overflow") // ErrUint64AddOverflow is returned if when adding uint64 values overflow uint64 ErrUint64AddOverflow = errors.New("uint64 addition overflow") // ErrInt64AddOverflow is returned if when adding int64 values overflow int64 ErrInt64AddOverflow = errors.New("int64 addition overflow") // ErrInt32AddOverflow is returned if when adding int32 values overflow int64 ErrInt32AddOverflow = errors.New("int64 addition overflow") // ErrIntAddOverflow is returned if when adding int values overflow int64 ErrIntAddOverflow = errors.New("int64 addition overflow") // ErrUint64MinusOverflow is returned if when subtracting uint64 values overflow uint64 ErrUint64MinusOverflow = errors.New("uint64 minus overflow") // ErrUint64OverflowsInt64 is returned if when converting a uint64 to an int64 overflow int64 ErrUint64OverflowsInt64 = errors.New("uint64 overflows int64") // ErrUint64OverflowsFloat64 is returned if when converting a uint64 to a float64 overflow float64 ErrUint64OverflowsFloat64 = errors.New("uint64 overflows float64") // ErrInt64UnderflowsUint64 is returned if when converting an int64 to a uint64 underflow uint64 ErrInt64UnderflowsUint64 = errors.New("int64 underflows uint64") // ErrFloat64UnderflowsUint64 is returned if when converting an float6464 to a uint64 underflow uint64 ErrFloat64UnderflowsUint64 = errors.New("float64 underflows uint64") )
Functions ¶
This section is empty.
Types ¶
type Coin ¶
type Coin uint64
Coin - any quantity that is represented as an integer in the lowest denomination
func Float64ToCoin ¶
Float64ToCoin converts an float64 to a uint64 Coin, returning an error if the float64 value underflows uint64
func Int64ToCoin ¶
Int64ToCoin converts an int64 to a uint64 Coin, returning an error if the int64 value underflows uint64
func MinusInt64 ¶
MinusInt64 subtracts a from c, returning an error if the values overflow
func MultFloat64 ¶
MultFloat64 multiplies c by a, returning an error if the values overflow
func (Coin) Float64 ¶
Float64 converts c uint64 Coin to a float64, returning an error if the uint64 value overflows float64
func (Coin) Int64 ¶
Int64 converts c uint64 Coin to an int64, returning an error if the uint64 value overflows int64
func (Coin) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler