decimal

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const GASPrecision = 8

GASPrecision contains precision for NEO Gas token.

Variables

View Source
var (
	ErrInvalidLengthDecimal        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowDecimal          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupDecimal = fmt.Errorf("proto: unexpected end of group")
)
View Source
var Zero = &Decimal{}

Zero is empty Decimal value.

Functions

This section is empty.

Types

type Decimal

type Decimal struct {
	// Value is value number
	Value int64 `protobuf:"varint,1,opt,name=Value,proto3" json:"Value,omitempty"`
	// Precision is precision number
	Precision            uint32   `protobuf:"varint,2,opt,name=Precision,proto3" json:"Precision,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Decimal is a structure used for representation of assets amount

func New

func New(v int64) *Decimal

New returns new Decimal (in satoshi).

func NewGAS

func NewGAS(v int64) *Decimal

NewGAS returns new Decimal * 1e8 (in GAS).

func NewWithPrecision

func NewWithPrecision(v int64, p uint32) *Decimal

NewWithPrecision returns new Decimal with custom precision.

func ParseFloat

func ParseFloat(v float64) *Decimal

ParseFloat return new Decimal parsed from float64 * 1e8 (in GAS).

func ParseFloatWithPrecision

func ParseFloatWithPrecision(v float64, p int) *Decimal

ParseFloatWithPrecision returns new Decimal parsed from float64 * 1^p.

func (Decimal) Add

func (m Decimal) Add(d *Decimal) *Decimal

Add returns d + m.

func (*Decimal) Copy

func (m *Decimal) Copy() *Decimal

Copy returns copy of current Decimal.

func (*Decimal) Descriptor

func (*Decimal) Descriptor() ([]byte, []int)

func (Decimal) Equal

func (m Decimal) Equal(v *Decimal) bool

Equal checks that current Decimal is equal to passed Decimal.

func (Decimal) GT

func (m Decimal) GT(v *Decimal) bool

GT checks that m > v.

func (Decimal) GTE

func (m Decimal) GTE(v *Decimal) bool

GTE checks that m >= v.

func (*Decimal) GetPrecision

func (m *Decimal) GetPrecision() uint32

func (*Decimal) GetValue

func (m *Decimal) GetValue() int64

func (Decimal) LT

func (m Decimal) LT(v *Decimal) bool

LT checks that m < v.

func (Decimal) LTE

func (m Decimal) LTE(v *Decimal) bool

LTE checks that m <= v.

func (*Decimal) Marshal

func (m *Decimal) Marshal() (dAtA []byte, err error)

func (*Decimal) MarshalTo

func (m *Decimal) MarshalTo(dAtA []byte) (int, error)

func (*Decimal) MarshalToSizedBuffer

func (m *Decimal) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (Decimal) Neg

func (m Decimal) Neg() *Decimal

Neg returns negative representation of current Decimal (m * -1).

func (*Decimal) Parse

func (m *Decimal) Parse(v float64, p int) *Decimal

Parse returns parsed Decimal from float64 * 1^p.

func (*Decimal) ProtoMessage

func (*Decimal) ProtoMessage()

func (*Decimal) Reset

func (m *Decimal) Reset()

func (*Decimal) Size

func (m *Decimal) Size() (n int)

func (Decimal) String

func (m Decimal) String() string

String returns string representation of Decimal.

func (*Decimal) Unmarshal

func (m *Decimal) Unmarshal(dAtA []byte) error

func (*Decimal) XXX_DiscardUnknown

func (m *Decimal) XXX_DiscardUnknown()

func (*Decimal) XXX_Marshal

func (m *Decimal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Decimal) XXX_Merge

func (m *Decimal) XXX_Merge(src proto.Message)

func (*Decimal) XXX_Size

func (m *Decimal) XXX_Size() int

func (*Decimal) XXX_Unmarshal

func (m *Decimal) XXX_Unmarshal(b []byte) error

func (Decimal) Zero

func (m Decimal) Zero() bool

Zero checks that Decimal is empty.

Jump to

Keyboard shortcuts

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