Documentation ¶
Index ¶
- Constants
- Variables
- func Cmp(a, b Amount) int
- type Amount
- func Add(a, b Amount) Amount
- func Mul(a, b Amount) Amount
- func MustNewFromString(v string) Amount
- func NewFromBigInt(v *big.Int) Amount
- func NewFromInt(v int64) Amount
- func NewFromIntWithPrecision(v *big.Int, precision int) Amount
- func NewFromString(s string) (Amount, error)
- func Sub(a, b Amount) Amount
- func Sum(amounts ...Amount) Amount
- func (a Amount) Float() float64
- func (a Amount) Int() *big.Int
- func (a Amount) IntWithPrecision(precision int) *big.Int
- func (a Amount) MarshalJSON() ([]byte, error)
- func (a *Amount) Scan(src interface{}) error
- func (a Amount) String() string
- func (a *Amount) UnmarshalJSON(data []byte) error
- func (a Amount) Value() (driver.Value, error)
Constants ¶
View Source
const DefaultPrecision = 24
Variables ¶
View Source
var One, _ = big.NewInt(0).SetString("1000000000000000000000000", 10)
Functions ¶
Types ¶
type Amount ¶
Amount is a wrapper around big.Int that implements decimal numbers with max precision of 18 digits
func MustNewFromString ¶
func NewFromBigInt ¶
func NewFromInt ¶
func NewFromIntWithPrecision ¶
NewFromIntWithPrecision creates a new Amount from an integer with the specified precision For example, if v = 100000 and precision = 3 the result amount will be 100.000
func NewFromString ¶
func (Amount) IntWithPrecision ¶
IntWithPrecision returns a big.Int representation of number with the specified precision For example, if v = 100.000 and precision = 3 the result amount will be 100000 if v = 100.000 and precision = 5 the result amount will be 10000000
func (Amount) MarshalJSON ¶
func (*Amount) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.