unit

package
v0.0.0-...-5a547ea Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 8 Imported by: 1

README

unit

  • Still in development :)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FloatPricePrecision int     = 2
	FloatPricePow       float64 = math.Pow10(FloatPricePrecision)
)
View Source
var (
	IntPricePrecision int     = 2
	IntPricePow       float64 = math.Pow10(IntPricePrecision)
)

Functions

func CurrencyMapping

func CurrencyMapping(s string) string

func CurrencyUnMapping

func CurrencyUnMapping(mapping string) string

func SetCurrencyMapping

func SetCurrencyMapping(s, mapping string)

func SetCurrencyMappingFunc

func SetCurrencyMappingFunc(f func(string) string)

func SetCurrencyMappingPair

func SetCurrencyMappingPair(s, mapping string)

func SetCurrencyUnMapping

func SetCurrencyUnMapping(s, mapping string)

func SetCurrencyUnMappingFunc

func SetCurrencyUnMappingFunc(f func(string) string)

func SetFloatPricePrecision

func SetFloatPricePrecision(e int)

func SetIntPricePrecision

func SetIntPricePrecision(e int)

Types

type Currency

type Currency string

func NewCurrency

func NewCurrency(s string) Currency

func (*Currency) Equal

func (c *Currency) Equal(s Currency) bool

func (*Currency) EqualString

func (c *Currency) EqualString(s string) bool

func (*Currency) MarshalJSON

func (c *Currency) MarshalJSON() ([]byte, error)

func (*Currency) Scan

func (c *Currency) Scan(src interface{}) error

func (*Currency) SetString

func (c *Currency) SetString(s string) *Currency

func (Currency) String

func (c Currency) String() string

func (Currency) StringMapping

func (c Currency) StringMapping() string

func (*Currency) UnmarshalJSON

func (c *Currency) UnmarshalJSON(data []byte) error

func (Currency) Value

func (c Currency) Value() (driver.Value, error)

type FloatPrice

type FloatPrice float64

func NewFloatPrice

func NewFloatPrice(f float64, places ...int) FloatPrice

func NewFloatPriceInt

func NewFloatPriceInt(i int64, places ...int) FloatPrice

func NewFloatPriceIntString

func NewFloatPriceIntString(value string, places ...int) FloatPrice

func NewFloatPriceString

func NewFloatPriceString(value string, places ...int) FloatPrice

func (*FloatPrice) Add

func (p *FloatPrice) Add(q FloatPrice) *FloatPrice

rounded p+q and returns p

func (FloatPrice) Cmp

func (p FloatPrice) Cmp(q FloatPrice) int

Cmp compares p and p and returns:

-1 if p <  p
 0 if p == p (incl. -0 == 0, -Inf == -Inf, and +Inf == +Inf)
+1 if p >  p

func (*FloatPrice) Diff

func (p *FloatPrice) Diff(x ...FloatPrice) *FloatPrice

rounded p-x... and returns p

func (*FloatPrice) Equal

func (p *FloatPrice) Equal(f float64) bool

func (FloatPrice) Float64

func (p FloatPrice) Float64() float64

func (FloatPrice) GetDiff

func (p FloatPrice) GetDiff(x ...FloatPrice) FloatPrice

rounded p+x... and returns

func (FloatPrice) GetDiv

func (p FloatPrice) GetDiv(x ...FloatPrice) FloatPrice

rounded quotient p/q... and returns

func (FloatPrice) GetMul

func (p FloatPrice) GetMul(x ...FloatPrice) FloatPrice

rounded product p*q... and returns

func (FloatPrice) GetNegation

func (p FloatPrice) GetNegation() FloatPrice

returns negation

func (FloatPrice) GetSum

func (p FloatPrice) GetSum(x ...FloatPrice) FloatPrice

rounded p+x... and returns

func (*FloatPrice) GreaterEqual

func (p *FloatPrice) GreaterEqual(f float64) bool

func (*FloatPrice) GreaterThan

func (p *FloatPrice) GreaterThan(f float64) bool

func (FloatPrice) Int64

func (p FloatPrice) Int64() int64

func (*FloatPrice) IsNegative

func (p *FloatPrice) IsNegative() bool

func (*FloatPrice) IsPositive

func (p *FloatPrice) IsPositive() bool

func (*FloatPrice) IsZero

func (p *FloatPrice) IsZero() bool

func (*FloatPrice) LessEqual

func (p *FloatPrice) LessEqual(f float64) bool

func (*FloatPrice) LessThan

func (p *FloatPrice) LessThan(f float64) bool

func (*FloatPrice) MarshalJSON

func (p *FloatPrice) MarshalJSON() ([]byte, error)

func (*FloatPrice) Mul

func (p *FloatPrice) Mul(q FloatPrice) *FloatPrice

rounded product p*q and returns p

func (*FloatPrice) Quo

func (p *FloatPrice) Quo(q FloatPrice) *FloatPrice

rounded quotient p/q and returns p

func (FloatPrice) ReciprocalFloat64

func (p FloatPrice) ReciprocalFloat64(places ...int) float64

func (*FloatPrice) Round

func (p *FloatPrice) Round(places int) *FloatPrice

func (*FloatPrice) Scan

func (p *FloatPrice) Scan(src interface{}) error

func (*FloatPrice) SetFloat64

func (p *FloatPrice) SetFloat64(f float64, places ...int) *FloatPrice

func (*FloatPrice) SetInt64

func (p *FloatPrice) SetInt64(i int64, places ...int) *FloatPrice

func (FloatPrice) String

func (p FloatPrice) String() string

func (FloatPrice) StringFloat

func (p FloatPrice) StringFloat() string

func (FloatPrice) StringInt

func (p FloatPrice) StringInt() string

func (*FloatPrice) Sub

func (p *FloatPrice) Sub(q FloatPrice) *FloatPrice

rounded p-q and returns p

func (*FloatPrice) Sum

func (p *FloatPrice) Sum(x ...FloatPrice) *FloatPrice

rounded p+x... and returns p

func (*FloatPrice) UnmarshalJSON

func (p *FloatPrice) UnmarshalJSON(data []byte) error

func (FloatPrice) Value

func (p FloatPrice) Value() (driver.Value, error)

func (*FloatPrice) Zero

func (p *FloatPrice) Zero()

type IntPrice

type IntPrice int64
const (
	MaxIntPrice IntPrice = IntPrice(math.MaxInt64)
	MinIntPrice IntPrice = IntPrice(math.MinInt64)
)

func NewIntPrice

func NewIntPrice(value int64) IntPrice

func NewIntPriceFloat

func NewIntPriceFloat(value float64, places ...int) IntPrice

func NewIntPriceFloatString

func NewIntPriceFloatString(value string) IntPrice

func NewIntPriceString

func NewIntPriceString(value string) IntPrice

func (*IntPrice) Add

func (p *IntPrice) Add(q IntPrice) *IntPrice

rounded p+q and returns p

func (IntPrice) Cmp

func (p IntPrice) Cmp(q IntPrice) int

Cmp compares p and p and returns:

-1 if p <  p
 0 if p == p (incl. -0 == 0, -Inf == -Inf, and +Inf == +Inf)
+1 if p >  p

func (*IntPrice) Diff

func (p *IntPrice) Diff(x ...IntPrice) *IntPrice

rounded p-x... and returns p

func (*IntPrice) Equal

func (p *IntPrice) Equal(f float64) bool

func (IntPrice) Float64

func (p IntPrice) Float64() float64

func (IntPrice) GetDiff

func (p IntPrice) GetDiff(x ...IntPrice) IntPrice

rounded p+x... and returns

func (IntPrice) GetMul

func (p IntPrice) GetMul(x ...IntPrice) IntPrice

rounded product p*+x... and returns p

func (IntPrice) GetNegation

func (p IntPrice) GetNegation() IntPrice

returns negation

func (IntPrice) GetQuo

func (p IntPrice) GetQuo(x ...IntPrice) IntPrice

rounded quotient p/+x... and returns p

func (IntPrice) GetSum

func (p IntPrice) GetSum(x ...IntPrice) IntPrice

rounded p+x... and returns

func (*IntPrice) GreaterEqual

func (p *IntPrice) GreaterEqual(f float64) bool

func (*IntPrice) GreaterThan

func (p *IntPrice) GreaterThan(f float64) bool

func (IntPrice) Int64

func (p IntPrice) Int64() int64

func (*IntPrice) IsNegative

func (p *IntPrice) IsNegative() bool

func (*IntPrice) IsPositive

func (p *IntPrice) IsPositive() bool

func (*IntPrice) IsZero

func (p *IntPrice) IsZero() bool

func (*IntPrice) LessEqual

func (p *IntPrice) LessEqual(f float64) bool

func (*IntPrice) LessThan

func (p *IntPrice) LessThan(f float64) bool

func (*IntPrice) MarshalJSON

func (p *IntPrice) MarshalJSON() ([]byte, error)

func (*IntPrice) Mul

func (p *IntPrice) Mul(q IntPrice) *IntPrice

rounded product p*q and returns p

func (*IntPrice) Quo

func (p *IntPrice) Quo(q IntPrice) *IntPrice

rounded quotient p/q and returns p

func (IntPrice) ReciprocalFloat64

func (p IntPrice) ReciprocalFloat64(places ...int) float64

func (*IntPrice) Round

func (p *IntPrice) Round(places int) *IntPrice

func (*IntPrice) Scan

func (p *IntPrice) Scan(src interface{}) error

func (*IntPrice) SetFloat64

func (p *IntPrice) SetFloat64(f float64, places ...int) *IntPrice

func (*IntPrice) SetInt64

func (p *IntPrice) SetInt64(i int64) *IntPrice

func (IntPrice) String

func (p IntPrice) String() string

func (IntPrice) StringFloat

func (p IntPrice) StringFloat() string

func (*IntPrice) Sub

func (p *IntPrice) Sub(q IntPrice) *IntPrice

rounded p-q and returns p

func (*IntPrice) Sum

func (p *IntPrice) Sum(x ...IntPrice) *IntPrice

rounded p+x... and returns p

func (*IntPrice) UnmarshalJSON

func (p *IntPrice) UnmarshalJSON(data []byte) error

func (IntPrice) Value

func (p IntPrice) Value() (driver.Value, error)

func (*IntPrice) Zero

func (p *IntPrice) Zero()

Jump to

Keyboard shortcuts

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