dec

package module
v0.0.0-...-a688eb9 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2018 License: MIT Imports: 2 Imported by: 0

README

dec

Fixed point decimal library

  • Stored as int64 multiplied by 1billion (9 decimal places)
  • All arithmetic operations except multiply and divide work as normal (use the Mul and Div functions)
  • JSON/XML/SQL/gob serializable
  • Convenience functions for common operations (avg, max, min, round, truncate etc)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decimal

type Decimal int64

func Avg

func Avg(first Decimal, rest ...Decimal) Decimal

func Max

func Max(first Decimal, rest ...Decimal) Decimal

func Min

func Min(first Decimal, rest ...Decimal) Decimal

func New

func New(intPart int64, decimalPart int32) Decimal

func NewFromDecimal

func NewFromDecimal(d decimal.Decimal) Decimal

func NewFromFloat

func NewFromFloat(value float64) Decimal

func NewFromFloat32

func NewFromFloat32(value float32) Decimal

func NewFromString

func NewFromString(value string) (Decimal, error)

func RequireFromString

func RequireFromString(value string) Decimal

func Sum

func Sum(first Decimal, rest ...Decimal) (sum Decimal)

func (Decimal) Abs

func (d Decimal) Abs() Decimal

func (Decimal) Cmp

func (d Decimal) Cmp(d2 Decimal) int

func (Decimal) Decimal

func (d Decimal) Decimal() decimal.Decimal

func (Decimal) Div

func (d Decimal) Div(d2 Decimal) Decimal

func (Decimal) DivRound

func (d Decimal) DivRound(d2 Decimal, precision int8) Decimal

func (Decimal) Float64

func (d Decimal) Float64() (f float64, exact bool)

func (Decimal) Floor

func (d Decimal) Floor() Decimal

func (*Decimal) GobDecode

func (d *Decimal) GobDecode(data []byte) (err error)

func (Decimal) GobEncode

func (d Decimal) GobEncode() ([]byte, error)

func (Decimal) IntPart

func (d Decimal) IntPart() int64

func (Decimal) MarshalBinary

func (d Decimal) MarshalBinary() ([]byte, error)

func (Decimal) MarshalJSON

func (d Decimal) MarshalJSON() ([]byte, error)

func (Decimal) MarshalText

func (d Decimal) MarshalText() ([]byte, error)

func (Decimal) Mul

func (d Decimal) Mul(d2 Decimal) Decimal

func (Decimal) Round

func (d Decimal) Round(places int8) Decimal

func (Decimal) RoundBank

func (d Decimal) RoundBank(places int8) Decimal

func (Decimal) RoundCash

func (d Decimal) RoundCash(interval uint8) Decimal

func (*Decimal) Scan

func (d *Decimal) Scan(value interface{}) (err error)

func (Decimal) Shift

func (d Decimal) Shift(shift int8) Decimal

func (Decimal) Sign

func (d Decimal) Sign() int

func (Decimal) String

func (d Decimal) String() string

func (Decimal) StringFixed

func (d Decimal) StringFixed(places int8) string

func (Decimal) StringFixedBank

func (d Decimal) StringFixedBank(places int8) string

func (Decimal) StringFixedCash

func (d Decimal) StringFixedCash(interval uint8) string

func (Decimal) Truncate

func (d Decimal) Truncate(precision int8) Decimal

func (*Decimal) UnmarshalBinary

func (d *Decimal) UnmarshalBinary(data []byte) (err error)

func (*Decimal) UnmarshalJSON

func (d *Decimal) UnmarshalJSON(decimalBytes []byte) (err error)

func (*Decimal) UnmarshalText

func (d *Decimal) UnmarshalText(text []byte) (err error)

func (Decimal) Value

func (d Decimal) Value() (driver.Value, error)

type NullDecimal

type NullDecimal struct {
	Decimal
	Valid bool
}

func NewFromNullDecimal

func NewFromNullDecimal(d decimal.NullDecimal) NullDecimal

func (NullDecimal) MarshalJSON

func (d NullDecimal) MarshalJSON() ([]byte, error)

func (NullDecimal) NullDecimal

func (d NullDecimal) NullDecimal() decimal.NullDecimal

func (*NullDecimal) Scan

func (d *NullDecimal) Scan(value interface{}) (err error)

func (*NullDecimal) UnmarshalJSON

func (d *NullDecimal) UnmarshalJSON(decimalBytes []byte) (err error)

func (NullDecimal) Value

func (d NullDecimal) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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