Numbers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var INT128_LIMIT = new(big.Int).SetBytes([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})

Functions

This section is empty.

Types

type HumanAmount

type HumanAmount struct {
	// contains filtered or unexported fields
}

func NewHumanFromRaw

func NewHumanFromRaw(n *RawAmount) *HumanAmount

func NewHumanFromString

func NewHumanFromString(n string, base UnitBase) *HumanAmount

func (*HumanAmount) ConvertToBase

func (n *HumanAmount) ConvertToBase(base UnitBase, scale int) (string, error)

func (*HumanAmount) ConvertToRawAmount

func (n *HumanAmount) ConvertToRawAmount() (*RawAmount, error)

type RawAmount

type RawAmount struct {
	// contains filtered or unexported fields
}

func NewRawFromBytes

func NewRawFromBytes(b []byte) (*RawAmount, error)

NewRawFromBytes creates an RawAmount from byte-array. It returns an non-nil error if the string is invalid and nil successful.

func NewRawFromHex

func NewRawFromHex(h string) (*RawAmount, error)

NewRawFromHex creates an RawAmount from hexadecimal string. It returns an non-nil error if the value is invalid.

func NewRawFromString

func NewRawFromString(s string) (*RawAmount, error)

NewRawFromString creates an RawAmount from numeric string. It returns an error if the string is invalid and nil successful.

func (*RawAmount) Add

func (a *RawAmount) Add(b *RawAmount) *RawAmount

Add adds the a by b

func (*RawAmount) Compare

func (a *RawAmount) Compare(b *RawAmount) int

Compare compares a with b, return -1 if a < b

0 if a == b

+1 if a > b

func (*RawAmount) Divide

func (a *RawAmount) Divide(b *RawAmount) *RawAmount

Divide divides the a by b

func (*RawAmount) IsValid

func (a *RawAmount) IsValid() bool

func (*RawAmount) MarshalJSON

func (d *RawAmount) MarshalJSON() ([]byte, error)

func (*RawAmount) Multiply

func (a *RawAmount) Multiply(b *RawAmount) *RawAmount

Multiply multiplies the a by b

func (*RawAmount) Subtract

func (a *RawAmount) Subtract(b *RawAmount) *RawAmount

Subtract subtracts the a by b

func (*RawAmount) ToBytes

func (a *RawAmount) ToBytes() []byte

ToBytes transforms the RawAmount to 16 byte, left zero-padded. It can be used in block signature and in RPC.

func (*RawAmount) ToHex

func (a *RawAmount) ToHex() string

ToPaddedHex transforms the RawAmount to hexadecimal string with 16 byte, left zero-padded. It can be used in RPC.

func (*RawAmount) ToString

func (a *RawAmount) ToString() string

ToString transforms the RawAmount to string, which can be printable.

func (*RawAmount) UnmarshalJSON

func (d *RawAmount) UnmarshalJSON(data []byte) (err error)

type UnitBase

type UnitBase int
const (
	MicroXRB UnitBase = 18 + (3 * iota)
	MiliXRB
	XRB
	KiloXRB
	MegaXRB
	GigaXRB
	RAW UnitBase = 0
)

Jump to

Keyboard shortcuts

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