amount

package
v0.0.0-...-24e5678 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const FractionalCount = 18

FractionalCount represent the number of under the float point

View Source
const FractionalMax = 1000000000000000000

FractionalMax represent the max value of under the float point

Variables

View Source
var (
	ErrInvalidAmountFormat = errors.New("invalid amount format")
)

amount errors

View Source
var ZeroCoin = NewAmount(0, 0)

Functions

This section is empty.

Types

type Amount

type Amount struct {
	*big.Int
}

Amount is the precision float value based on the big.Int

func MustParseAmount

func MustParseAmount(str string) *Amount

MustParseAmount parse the amount from the float string

func NewAmount

func NewAmount(i uint64, f uint64) *Amount

NewAmount returns the amount that is consisted of the integer and the fractional value

func NewAmountFromBytes

func NewAmountFromBytes(bs []byte) *Amount

NewAmountFromBytes parse the amount from the byte array

func ParseAmount

func ParseAmount(str string) (*Amount, error)

ParseAmount parse the amount from the float string

func (*Amount) Add

func (am *Amount) Add(b *Amount) *Amount

Add returns a + b (*immutable)

func (*Amount) Clone

func (am *Amount) Clone() *Amount

Clone returns the clonend value of it

func (*Amount) Div

func (am *Amount) Div(b *Amount) *Amount

Div returns a / b (*immutable)

func (*Amount) DivC

func (am *Amount) DivC(b int64) *Amount

DivC returns a / b (*immutable)

func (*Amount) Equal

func (am *Amount) Equal(b *Amount) bool

Equal checks that two values is same or not

func (*Amount) IsMinus

func (am *Amount) IsMinus() bool

Less returns a < 0

func (*Amount) IsPlus

func (am *Amount) IsPlus() bool

Less returns a > 0

func (*Amount) IsZero

func (am *Amount) IsZero() bool

IsZero returns a == 0

func (*Amount) Less

func (am *Amount) Less(b *Amount) bool

Less returns a < b

func (*Amount) MarshalJSON

func (am *Amount) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*Amount) Mul

func (am *Amount) Mul(b *Amount) *Amount

Mul returns a * b (*immutable)

func (*Amount) MulC

func (am *Amount) MulC(b int64) *Amount

MulC returns a * b (*immutable)

func (*Amount) String

func (am *Amount) String() string

String returns the float string of the amount

func (*Amount) Sub

func (am *Amount) Sub(b *Amount) *Amount

Sub returns a - b (*immutable)

func (*Amount) UnmarshalJSON

func (am *Amount) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

Jump to

Keyboard shortcuts

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