Documentation ¶
Index ¶
- Variables
- func Move(dst, src, n *Quantity) error
- type Quantity
- func (q *Quantity) Add(n *Quantity) error
- func (q *Quantity) Clone() *Quantity
- func (q *Quantity) Cmp(n *Quantity) int
- func (q *Quantity) FromBigInt(n *big.Int) error
- func (q *Quantity) FromInt64(n int64) error
- func (q *Quantity) FromUint64(n uint64) error
- func (q *Quantity) IsValid() bool
- func (q *Quantity) IsZero() bool
- func (q *Quantity) MarshalBinary() ([]byte, error)
- func (q Quantity) MarshalText() ([]byte, error)
- func (q *Quantity) Mul(n *Quantity) error
- func (q *Quantity) Quo(n *Quantity) error
- func (q Quantity) String() string
- func (q *Quantity) Sub(n *Quantity) error
- func (q *Quantity) SubUpTo(n *Quantity) (*Quantity, error)
- func (q *Quantity) ToBigInt() *big.Int
- func (q *Quantity) UnmarshalBinary(data []byte) error
- func (q *Quantity) UnmarshalText(text []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidQuantity is the error returned on malformed arguments. ErrInvalidQuantity = errors.New("invalid quantity") // ErrInsufficientBalance is the error returned when an operation // fails due to insufficient balance. ErrInsufficientBalance = errors.New("insufficient balance") // ErrInvalidAccount is the error returned when an operation fails // due to a missing account. ErrInvalidAccount = errors.New("invalid account") )
Functions ¶
Types ¶
type Quantity ¶
type Quantity struct {
// contains filtered or unexported fields
}
Quantity is a arbitrary precision unsigned integer that never underflows.
func MoveUpTo ¶
MoveUpTo moves up to n from src to dst, and returns the amount moved. On failures neither src nor dst are altered.
func NewFromUint64 ¶
NewFromUint64 creates a new Quantity from an uint64 or panics.
func NewQuantity ¶
func NewQuantity() (q *Quantity)
New creates a new Quantity, initialized to zero.
func (*Quantity) FromBigInt ¶
FromBigInt converts from a big.Int to a Quantity.
func (*Quantity) FromUint64 ¶
FromUint64 converts from an uint64 to a Quantity.
func (*Quantity) MarshalBinary ¶
MarshalBinary encodes a Quantity into binary form.
func (Quantity) MarshalText ¶
MarshalText encodes a Quantity into text form.
func (*Quantity) Sub ¶
Sub subtracts exactly n from q, returning an error if q < n, n < 0 or n == nil.
func (*Quantity) SubUpTo ¶
SubUpTo subtracts up to n from q, and returns the amount subtracted, returning an error if n < 0 or n == nil.
func (*Quantity) UnmarshalBinary ¶
UnmarshalBinary decodes a byte slice into a Quantity.
func (*Quantity) UnmarshalText ¶
UnmarshalText decodes a text slice into a Quantity.