fixed

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 6 Imported by: 5

README

fixed

golang fixed number support library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRHS = errors.New("right hand side operator value must has same decimals", errVendor, errors.WithCode(-1))
)

errors.

Functions

This section is empty.

Types

type Number

type Number struct {
	RawValue *big.Int `json:"raw"`
	Decimals int      `json:"decimals"`
}

Number the fixed number present object

func New

func New(decimals int, source Source) (*Number, error)

New create fixed number object

func (*Number) Add

func (number *Number) Add(other *Number) *Number

Add x add y and return new fixed number object

func (*Number) Cmp

func (number *Number) Cmp(other *Number) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

func (*Number) Float added in v0.0.2

func (number *Number) Float() *big.Float

Float .

func (*Number) HexRawValue

func (number *Number) HexRawValue() string

HexRawValue get rawvalue's hex string

func (*Number) Sign

func (number *Number) Sign() int

Sign get fixed number sign

func (*Number) String

func (number *Number) String() string

func (*Number) Sub

func (number *Number) Sub(other *Number) *Number

Sub x sub y and return new fixed number object

type Source

type Source func(decimals int) (*big.Int, error)

Source raw value source

func BigFloat

func BigFloat(value *big.Float) Source

BigFloat .

func BigInt

func BigInt(value *big.Int) Source

BigInt .

func Float

func Float(value float64) Source

Float .

func HexRawValue

func HexRawValue(source string) Source

HexRawValue .

func Int

func Int(value int64) Source

Int .

Jump to

Keyboard shortcuts

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