fixedpoint

package
v1.59.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 8 Imported by: 125

Documentation

Index

Constants

View Source
const DefaultPow = 1e8
View Source
const DefaultPrecision = 8
View Source
const MaxPrecision = 12
View Source
const NegInf = Value(math.MinInt64)
View Source
const NegOne = Value(-1e8)
View Source
const One = Value(1e8)
View Source
const PosInf = Value(math.MaxInt64)
View Source
const Zero = Value(0)

Variables

View Source
var ErrPrecisionLoss = errors.New("precision loss")

Functions

func Compare added in v1.28.0

func Compare(x, y Value) int

func Count added in v1.40.3

func Count(values []Value, counter Counter) int

func Equal added in v1.28.0

func Equal(x, y Value) bool

func NegativeTester added in v1.40.3

func NegativeTester(value Value) bool

func Parse added in v1.14.0

func Parse(input string) (num int64, numDecimalPoints int, err error)

func PositiveTester added in v1.40.3

func PositiveTester(value Value) bool

Types

type Ascending added in v1.40.3

type Ascending []Value

func (Ascending) Len added in v1.40.3

func (s Ascending) Len() int

func (Ascending) Less added in v1.40.3

func (s Ascending) Less(i, j int) bool

func (Ascending) Swap added in v1.40.3

func (s Ascending) Swap(i, j int)

type Counter added in v1.40.3

type Counter func(a Value) bool

type Descending added in v1.40.3

type Descending []Value

func (Descending) Len added in v1.40.3

func (s Descending) Len() int

func (Descending) Less added in v1.40.3

func (s Descending) Less(i, j int) bool

func (Descending) Swap added in v1.40.3

func (s Descending) Swap(i, j int)

type Reducer added in v1.40.3

type Reducer func(prev, curr Value) Value

type RoundingMode added in v1.28.0

type RoundingMode int
const (
	Up RoundingMode = iota
	Down
	HalfUp
)

type Slice added in v1.40.3

type Slice []Value

func (Slice) Len added in v1.40.3

func (s Slice) Len() int

Defaults to ascending sort

func (Slice) Less added in v1.40.3

func (s Slice) Less(i, j int) bool

func (Slice) Reduce added in v1.40.3

func (s Slice) Reduce(reducer Reducer, a ...Value) Value

func (Slice) Swap added in v1.40.3

func (s Slice) Swap(i, j int)

type Tester added in v1.40.3

type Tester func(value Value) bool

type Value

type Value int64
var (
	Two   Value = NewFromInt(2)
	Three Value = NewFromInt(3)
	Four  Value = NewFromInt(4)
)

func Abs added in v1.17.0

func Abs(a Value) Value

func Avg added in v1.38.0

func Avg(values []Value) (avg Value)

func Clamp added in v1.45.0

func Clamp(x, min, max Value) Value

func Div added in v1.28.0

func Div(x, y Value) Value

func Filter added in v1.40.3

func Filter(values []Value, f Tester) (slice []Value)

func Max added in v1.11.0

func Max(a, b Value) Value

func Min added in v1.11.0

func Min(a, b Value) Value

func Mul added in v1.28.0

func Mul(x, y Value) Value

func Must

func Must(v Value, err error) Value

func MustNewFromBytes added in v1.28.0

func MustNewFromBytes(input []byte) (v Value)

func MustNewFromString added in v1.13.0

func MustNewFromString(input string) Value

func NewFromBytes added in v1.28.0

func NewFromBytes(input []byte) (Value, error)

func NewFromFloat

func NewFromFloat(val float64) Value

func NewFromInt

func NewFromInt(val int64) Value

func NewFromString

func NewFromString(input string) (Value, error)

func Reduce added in v1.40.3

func Reduce(values []Value, reducer Reducer, a ...Value) Value

func Sum added in v1.38.0

func Sum(values []Value) (s Value)

func SumReducer added in v1.40.3

func SumReducer(prev, curr Value) Value

func (Value) Abs added in v1.18.0

func (v Value) Abs() Value

func (Value) Add

func (v Value) Add(v2 Value) Value

func (*Value) AtomicAdd added in v1.2.0

func (v *Value) AtomicAdd(v2 Value)

func (*Value) AtomicLoad added in v1.2.0

func (v *Value) AtomicLoad() Value

func (Value) Ceil added in v1.17.0

func (v Value) Ceil() Value

func (Value) Clamp added in v1.45.0

func (x Value) Clamp(min, max Value) Value

func (Value) Compare added in v1.28.0

func (x Value) Compare(y Value) int

func (Value) Div

func (v Value) Div(v2 Value) Value

func (Value) Eq added in v1.28.0

func (x Value) Eq(y Value) bool

func (Value) Float64

func (v Value) Float64() float64

func (Value) Floor added in v1.14.0

func (v Value) Floor() Value

func (Value) FormatPercentage added in v1.28.0

func (v Value) FormatPercentage(prec int) string

func (Value) FormatString added in v1.28.0

func (v Value) FormatString(prec int) string

func (Value) Int added in v1.17.0

func (v Value) Int() int

func (Value) Int64

func (v Value) Int64() int64

func (Value) IsInf added in v1.40.0

func (a Value) IsInf() bool

func (Value) IsZero added in v1.28.0

func (v Value) IsZero() bool

func (Value) MarshalJSON added in v1.3.1

func (v Value) MarshalJSON() ([]byte, error)

func (Value) MarshalYAML added in v1.33.3

func (v Value) MarshalYAML() (interface{}, error)

func (Value) Mul

func (v Value) Mul(v2 Value) Value

func (Value) MulExp added in v1.28.0

func (a Value) MulExp(exp int) Value

func (Value) Neg added in v1.28.0

func (v Value) Neg() Value

func (Value) NumFractionalDigits added in v1.28.0

func (a Value) NumFractionalDigits() int

TODO: speedup

func (Value) NumIntDigits added in v1.28.0

func (a Value) NumIntDigits() int

func (Value) Percentage added in v1.18.0

func (v Value) Percentage() string

func (Value) Round added in v1.28.0

func (v Value) Round(r int, mode RoundingMode) Value

func (*Value) Scan added in v1.13.0

func (v *Value) Scan(src interface{}) error

func (Value) Sign added in v1.28.0

func (v Value) Sign() int

TODO inf

func (Value) SignedPercentage added in v1.18.0

func (v Value) SignedPercentage() string

func (Value) String added in v1.17.0

func (v Value) String() string

func (Value) Sub

func (v Value) Sub(v2 Value) Value

func (Value) Trunc added in v1.28.0

func (v Value) Trunc() Value

Trunc returns the integer portion (truncating any fractional part)

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(data []byte) error

func (*Value) UnmarshalYAML

func (v *Value) UnmarshalYAML(unmarshal func(a interface{}) error) (err error)

func (Value) Value added in v1.13.0

func (v Value) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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