fixed

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2019 License: MPL-2.0 Imports: 8 Imported by: 4

Documentation

Overview

Package fixed provides fixed-point values that can be added, subtracted, multiplied and divided.

Index

Constants

View Source
const (
	// F64d2Max holds the maximum F64d2 value.
	F64d2Max = F64d2(1<<63 - 1)
	// F64d2Min holds the minimum F64d2 value.
	F64d2Min = F64d2(^(1<<63 - 1))
)
View Source
const (
	// F64d3Max holds the maximum F64d3 value.
	F64d3Max = F64d3(1<<63 - 1)
	// F64d3Min holds the minimum F64d3 value.
	F64d3Min = F64d3(^(1<<63 - 1))
)
View Source
const (
	// F64d4Max holds the maximum F64d4 value.
	F64d4Max = F64d4(1<<63 - 1)
	// F64d4Min holds the minimum F64d4 value.
	F64d4Min = F64d4(^(1<<63 - 1))
)
View Source
const (
	// F64d6Max holds the maximum F64d6 value.
	F64d6Max = F64d6(1<<63 - 1)
	// F64d6Min holds the minimum F64d6 value.
	F64d6Min = F64d6(^(1<<63 - 1))
)
View Source
const (
	// Max holds the maximum fixed-point value.
	Max = Fixed(math.MaxInt64)
	// Min holds the minimum fixed-point value.
	Min = Fixed(math.MinInt64)
)

Variables

View Source
var (
	// F128d16Max holds the maximum F128d16 value.
	F128d16Max = F128d16{/* contains filtered or unexported fields */}
	// F128d16Min holds the minimum F128d16 value.
	F128d16Min = F128d16{/* contains filtered or unexported fields */}
)
View Source
var (
	// F128d2Max holds the maximum F128d2 value.
	F128d2Max = F128d2{/* contains filtered or unexported fields */}
	// F128d2Min holds the minimum F128d2 value.
	F128d2Min = F128d2{/* contains filtered or unexported fields */}
)
View Source
var (
	// F128d3Max holds the maximum F128d3 value.
	F128d3Max = F128d3{/* contains filtered or unexported fields */}
	// F128d3Min holds the minimum F128d3 value.
	F128d3Min = F128d3{/* contains filtered or unexported fields */}
)
View Source
var (
	// F128d4Max holds the maximum F128d4 value.
	F128d4Max = F128d4{/* contains filtered or unexported fields */}
	// F128d4Min holds the minimum F128d4 value.
	F128d4Min = F128d4{/* contains filtered or unexported fields */}
)
View Source
var (
	// F128d6Max holds the maximum F128d6 value.
	F128d6Max = F128d6{/* contains filtered or unexported fields */}
	// F128d6Min holds the minimum F128d6 value.
	F128d6Min = F128d6{/* contains filtered or unexported fields */}
)

Functions

func SetDigitsAfterDecimal

func SetDigitsAfterDecimal(digits int)

SetDigitsAfterDecimal controls the number of digits after the decimal place that are tracked. WARNING: This has a global effect on all fixed-point values and should only be set once prior to use of this package. Changes to this value invalidate any fixed-point values there were created prior to the call -- there is no enforcement of this, however, so use of a pre-existing value will quietly generate bad results.

Deprecated.

Types

type F128d16 added in v1.9.0

type F128d16 struct {
	// contains filtered or unexported fields
}

F128d16 holds a fixed-point value that contains up to 16 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F128d16FromFloat64 added in v1.9.0

func F128d16FromFloat64(value float64) F128d16

F128d16FromFloat64 creates a new F128d16 value from a float64.

func F128d16FromInt64 added in v1.9.0

func F128d16FromInt64(value int64) F128d16

F128d16FromInt64 creates a new F128d16 value from an int64.

func F128d16FromString added in v1.9.0

func F128d16FromString(str string) (F128d16, error)

F128d16FromString creates a new F128d16 value from a string.

func F128d16FromStringForced added in v1.9.0

func F128d16FromStringForced(str string) F128d16

F128d16FromStringForced creates a new F128d16 value from a string.

func (F128d16) Add added in v1.9.0

func (f F128d16) Add(value F128d16) F128d16

Add adds this value to the passed-in value, returning a new value.

func (F128d16) Comma added in v1.9.0

func (f F128d16) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F128d16) Div added in v1.9.0

func (f F128d16) Div(value F128d16) F128d16

Div divides this value by the passed-in value, returning a new value.

func (F128d16) Float64 added in v1.9.0

func (f F128d16) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F128d16) Int64 added in v1.9.0

func (f F128d16) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F128d16) MarshalText added in v1.9.0

func (f F128d16) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F128d16) Mul added in v1.9.0

func (f F128d16) Mul(value F128d16) F128d16

Mul multiplies this value by the passed-in value, returning a new value.

func (F128d16) String added in v1.9.0

func (f F128d16) String() string

func (F128d16) Sub added in v1.9.0

func (f F128d16) Sub(value F128d16) F128d16

Sub subtracts the passed-in value from this value, returning a new value.

func (F128d16) Trunc added in v1.9.0

func (f F128d16) Trunc() F128d16

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F128d16) UnmarshalText added in v1.9.0

func (f *F128d16) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F128d2 added in v1.9.0

type F128d2 struct {
	// contains filtered or unexported fields
}

F128d2 holds a fixed-point value that contains up to 2 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F128d2FromFloat64 added in v1.9.0

func F128d2FromFloat64(value float64) F128d2

F128d2FromFloat64 creates a new F128d2 value from a float64.

func F128d2FromInt64 added in v1.9.0

func F128d2FromInt64(value int64) F128d2

F128d2FromInt64 creates a new F128d2 value from an int64.

func F128d2FromString added in v1.9.0

func F128d2FromString(str string) (F128d2, error)

F128d2FromString creates a new F128d2 value from a string.

func F128d2FromStringForced added in v1.9.0

func F128d2FromStringForced(str string) F128d2

F128d2FromStringForced creates a new F128d2 value from a string.

func (F128d2) Add added in v1.9.0

func (f F128d2) Add(value F128d2) F128d2

Add adds this value to the passed-in value, returning a new value.

func (F128d2) Comma added in v1.9.0

func (f F128d2) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F128d2) Div added in v1.9.0

func (f F128d2) Div(value F128d2) F128d2

Div divides this value by the passed-in value, returning a new value.

func (F128d2) Float64 added in v1.9.0

func (f F128d2) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F128d2) Int64 added in v1.9.0

func (f F128d2) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F128d2) MarshalText added in v1.9.0

func (f F128d2) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F128d2) Mul added in v1.9.0

func (f F128d2) Mul(value F128d2) F128d2

Mul multiplies this value by the passed-in value, returning a new value.

func (F128d2) String added in v1.9.0

func (f F128d2) String() string

func (F128d2) Sub added in v1.9.0

func (f F128d2) Sub(value F128d2) F128d2

Sub subtracts the passed-in value from this value, returning a new value.

func (F128d2) Trunc added in v1.9.0

func (f F128d2) Trunc() F128d2

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F128d2) UnmarshalText added in v1.9.0

func (f *F128d2) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F128d3 added in v1.9.0

type F128d3 struct {
	// contains filtered or unexported fields
}

F128d3 holds a fixed-point value that contains up to 3 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F128d3FromFloat64 added in v1.9.0

func F128d3FromFloat64(value float64) F128d3

F128d3FromFloat64 creates a new F128d3 value from a float64.

func F128d3FromInt64 added in v1.9.0

func F128d3FromInt64(value int64) F128d3

F128d3FromInt64 creates a new F128d3 value from an int64.

func F128d3FromString added in v1.9.0

func F128d3FromString(str string) (F128d3, error)

F128d3FromString creates a new F128d3 value from a string.

func F128d3FromStringForced added in v1.9.0

func F128d3FromStringForced(str string) F128d3

F128d3FromStringForced creates a new F128d3 value from a string.

func (F128d3) Add added in v1.9.0

func (f F128d3) Add(value F128d3) F128d3

Add adds this value to the passed-in value, returning a new value.

func (F128d3) Comma added in v1.9.0

func (f F128d3) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F128d3) Div added in v1.9.0

func (f F128d3) Div(value F128d3) F128d3

Div divides this value by the passed-in value, returning a new value.

func (F128d3) Float64 added in v1.9.0

func (f F128d3) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F128d3) Int64 added in v1.9.0

func (f F128d3) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F128d3) MarshalText added in v1.9.0

func (f F128d3) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F128d3) Mul added in v1.9.0

func (f F128d3) Mul(value F128d3) F128d3

Mul multiplies this value by the passed-in value, returning a new value.

func (F128d3) String added in v1.9.0

func (f F128d3) String() string

func (F128d3) Sub added in v1.9.0

func (f F128d3) Sub(value F128d3) F128d3

Sub subtracts the passed-in value from this value, returning a new value.

func (F128d3) Trunc added in v1.9.0

func (f F128d3) Trunc() F128d3

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F128d3) UnmarshalText added in v1.9.0

func (f *F128d3) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F128d4 added in v1.9.0

type F128d4 struct {
	// contains filtered or unexported fields
}

F128d4 holds a fixed-point value that contains up to 4 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F128d4FromFloat64 added in v1.9.0

func F128d4FromFloat64(value float64) F128d4

F128d4FromFloat64 creates a new F128d4 value from a float64.

func F128d4FromInt64 added in v1.9.0

func F128d4FromInt64(value int64) F128d4

F128d4FromInt64 creates a new F128d4 value from an int64.

func F128d4FromString added in v1.9.0

func F128d4FromString(str string) (F128d4, error)

F128d4FromString creates a new F128d4 value from a string.

func F128d4FromStringForced added in v1.9.0

func F128d4FromStringForced(str string) F128d4

F128d4FromStringForced creates a new F128d4 value from a string.

func (F128d4) Add added in v1.9.0

func (f F128d4) Add(value F128d4) F128d4

Add adds this value to the passed-in value, returning a new value.

func (F128d4) Comma added in v1.9.0

func (f F128d4) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F128d4) Div added in v1.9.0

func (f F128d4) Div(value F128d4) F128d4

Div divides this value by the passed-in value, returning a new value.

func (F128d4) Float64 added in v1.9.0

func (f F128d4) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F128d4) Int64 added in v1.9.0

func (f F128d4) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F128d4) MarshalText added in v1.9.0

func (f F128d4) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F128d4) Mul added in v1.9.0

func (f F128d4) Mul(value F128d4) F128d4

Mul multiplies this value by the passed-in value, returning a new value.

func (F128d4) String added in v1.9.0

func (f F128d4) String() string

func (F128d4) Sub added in v1.9.0

func (f F128d4) Sub(value F128d4) F128d4

Sub subtracts the passed-in value from this value, returning a new value.

func (F128d4) Trunc added in v1.9.0

func (f F128d4) Trunc() F128d4

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F128d4) UnmarshalText added in v1.9.0

func (f *F128d4) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F128d6 added in v1.9.0

type F128d6 struct {
	// contains filtered or unexported fields
}

F128d6 holds a fixed-point value that contains up to 6 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F128d6FromFloat64 added in v1.9.0

func F128d6FromFloat64(value float64) F128d6

F128d6FromFloat64 creates a new F128d6 value from a float64.

func F128d6FromInt64 added in v1.9.0

func F128d6FromInt64(value int64) F128d6

F128d6FromInt64 creates a new F128d6 value from an int64.

func F128d6FromString added in v1.9.0

func F128d6FromString(str string) (F128d6, error)

F128d6FromString creates a new F128d6 value from a string.

func F128d6FromStringForced added in v1.9.0

func F128d6FromStringForced(str string) F128d6

F128d6FromStringForced creates a new F128d6 value from a string.

func (F128d6) Add added in v1.9.0

func (f F128d6) Add(value F128d6) F128d6

Add adds this value to the passed-in value, returning a new value.

func (F128d6) Comma added in v1.9.0

func (f F128d6) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F128d6) Div added in v1.9.0

func (f F128d6) Div(value F128d6) F128d6

Div divides this value by the passed-in value, returning a new value.

func (F128d6) Float64 added in v1.9.0

func (f F128d6) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F128d6) Int64 added in v1.9.0

func (f F128d6) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F128d6) MarshalText added in v1.9.0

func (f F128d6) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F128d6) Mul added in v1.9.0

func (f F128d6) Mul(value F128d6) F128d6

Mul multiplies this value by the passed-in value, returning a new value.

func (F128d6) String added in v1.9.0

func (f F128d6) String() string

func (F128d6) Sub added in v1.9.0

func (f F128d6) Sub(value F128d6) F128d6

Sub subtracts the passed-in value from this value, returning a new value.

func (F128d6) Trunc added in v1.9.0

func (f F128d6) Trunc() F128d6

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F128d6) UnmarshalText added in v1.9.0

func (f *F128d6) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F64d2 added in v1.9.0

type F64d2 int64

F64d2 holds a fixed-point value that contains up to 2 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F64d2FromFloat64 added in v1.9.0

func F64d2FromFloat64(value float64) F64d2

F64d2FromFloat64 creates a new F64d2 value from a float64.

func F64d2FromInt64 added in v1.9.0

func F64d2FromInt64(value int64) F64d2

F64d2FromInt64 creates a new F64d2 value from an int64.

func F64d2FromString added in v1.9.0

func F64d2FromString(str string) (F64d2, error)

F64d2FromString creates a new F64d2 value from a string.

func F64d2FromStringForced added in v1.9.0

func F64d2FromStringForced(str string) F64d2

F64d2FromStringForced creates a new F64d2 value from a string.

func (F64d2) Comma added in v1.9.0

func (f F64d2) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F64d2) Div added in v1.9.0

func (f F64d2) Div(value F64d2) F64d2

Div divides this value by the passed-in value, returning a new value.

func (F64d2) Float64 added in v1.9.0

func (f F64d2) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F64d2) Int64 added in v1.9.0

func (f F64d2) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F64d2) MarshalText added in v1.9.0

func (f F64d2) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F64d2) Mul added in v1.9.0

func (f F64d2) Mul(value F64d2) F64d2

Mul multiplies this value by the passed-in value, returning a new value.

func (F64d2) String added in v1.9.0

func (f F64d2) String() string

func (F64d2) Trunc added in v1.9.0

func (f F64d2) Trunc() F64d2

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F64d2) UnmarshalText added in v1.9.0

func (f *F64d2) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F64d3 added in v1.9.0

type F64d3 int64

F64d3 holds a fixed-point value that contains up to 3 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F64d3FromFloat64 added in v1.9.0

func F64d3FromFloat64(value float64) F64d3

F64d3FromFloat64 creates a new F64d3 value from a float64.

func F64d3FromInt64 added in v1.9.0

func F64d3FromInt64(value int64) F64d3

F64d3FromInt64 creates a new F64d3 value from an int64.

func F64d3FromString added in v1.9.0

func F64d3FromString(str string) (F64d3, error)

F64d3FromString creates a new F64d3 value from a string.

func F64d3FromStringForced added in v1.9.0

func F64d3FromStringForced(str string) F64d3

F64d3FromStringForced creates a new F64d3 value from a string.

func (F64d3) Comma added in v1.9.0

func (f F64d3) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F64d3) Div added in v1.9.0

func (f F64d3) Div(value F64d3) F64d3

Div divides this value by the passed-in value, returning a new value.

func (F64d3) Float64 added in v1.9.0

func (f F64d3) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F64d3) Int64 added in v1.9.0

func (f F64d3) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F64d3) MarshalText added in v1.9.0

func (f F64d3) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F64d3) Mul added in v1.9.0

func (f F64d3) Mul(value F64d3) F64d3

Mul multiplies this value by the passed-in value, returning a new value.

func (F64d3) String added in v1.9.0

func (f F64d3) String() string

func (F64d3) Trunc added in v1.9.0

func (f F64d3) Trunc() F64d3

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F64d3) UnmarshalText added in v1.9.0

func (f *F64d3) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F64d4 added in v1.9.0

type F64d4 int64

F64d4 holds a fixed-point value that contains up to 4 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F64d4FromFloat64 added in v1.9.0

func F64d4FromFloat64(value float64) F64d4

F64d4FromFloat64 creates a new F64d4 value from a float64.

func F64d4FromInt64 added in v1.9.0

func F64d4FromInt64(value int64) F64d4

F64d4FromInt64 creates a new F64d4 value from an int64.

func F64d4FromString added in v1.9.0

func F64d4FromString(str string) (F64d4, error)

F64d4FromString creates a new F64d4 value from a string.

func F64d4FromStringForced added in v1.9.0

func F64d4FromStringForced(str string) F64d4

F64d4FromStringForced creates a new F64d4 value from a string.

func (F64d4) Comma added in v1.9.0

func (f F64d4) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F64d4) Div added in v1.9.0

func (f F64d4) Div(value F64d4) F64d4

Div divides this value by the passed-in value, returning a new value.

func (F64d4) Float64 added in v1.9.0

func (f F64d4) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F64d4) Int64 added in v1.9.0

func (f F64d4) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F64d4) MarshalText added in v1.9.0

func (f F64d4) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F64d4) Mul added in v1.9.0

func (f F64d4) Mul(value F64d4) F64d4

Mul multiplies this value by the passed-in value, returning a new value.

func (F64d4) String added in v1.9.0

func (f F64d4) String() string

func (F64d4) Trunc added in v1.9.0

func (f F64d4) Trunc() F64d4

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F64d4) UnmarshalText added in v1.9.0

func (f *F64d4) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type F64d6 added in v1.9.0

type F64d6 int64

F64d6 holds a fixed-point value that contains up to 6 decimal places. Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

func F64d6FromFloat64 added in v1.9.0

func F64d6FromFloat64(value float64) F64d6

F64d6FromFloat64 creates a new F64d6 value from a float64.

func F64d6FromInt64 added in v1.9.0

func F64d6FromInt64(value int64) F64d6

F64d6FromInt64 creates a new F64d6 value from an int64.

func F64d6FromString added in v1.9.0

func F64d6FromString(str string) (F64d6, error)

F64d6FromString creates a new F64d6 value from a string.

func F64d6FromStringForced added in v1.9.0

func F64d6FromStringForced(str string) F64d6

F64d6FromStringForced creates a new F64d6 value from a string.

func (F64d6) Comma added in v1.9.0

func (f F64d6) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (F64d6) Div added in v1.9.0

func (f F64d6) Div(value F64d6) F64d6

Div divides this value by the passed-in value, returning a new value.

func (F64d6) Float64 added in v1.9.0

func (f F64d6) Float64() float64

Float64 returns the floating-point equivalent to this value.

func (F64d6) Int64 added in v1.9.0

func (f F64d6) Int64() int64

Int64 returns the truncated equivalent integer to this value.

func (F64d6) MarshalText added in v1.9.0

func (f F64d6) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (F64d6) Mul added in v1.9.0

func (f F64d6) Mul(value F64d6) F64d6

Mul multiplies this value by the passed-in value, returning a new value.

func (F64d6) String added in v1.9.0

func (f F64d6) String() string

func (F64d6) Trunc added in v1.9.0

func (f F64d6) Trunc() F64d6

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*F64d6) UnmarshalText added in v1.9.0

func (f *F64d6) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Fixed deprecated

type Fixed int64

Fixed holds a fixed-point value that contains up to N decimal places, where N is the value passed to SetDigitsAfterDecimal (default is 4). Values are truncated, not rounded. Values can be added and subtracted directly. For multiplication and division, the provided Mul() and Div() methods should be used.

Deprecated: Use one of the F64d... types instead.

func FromFloat64 deprecated

func FromFloat64(value float64) Fixed

FromFloat64 creates a new fixed-point value from a float64.

Deprecated: Use one of the F64d... types instead.

func FromInt deprecated

func FromInt(value int) Fixed

FromInt creates a new fixed-point value from an int.

Deprecated: Use one of the F64d... types instead.

func New deprecated

func New(value float64) Fixed

New creates a new fixed-point value.

Deprecated: Use FromFloat64() instead.

func Parse deprecated

func Parse(str string) (Fixed, error)

Parse a string to extract a fixed-point value from it.

Deprecated: Use one of the F64d... types instead.

func (Fixed) Comma

func (fxd Fixed) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (Fixed) Div

func (fxd Fixed) Div(value Fixed) Fixed

Div divides this value by the passed-in value, returning a new fixed-point value.

func (Fixed) Float64

func (fxd Fixed) Float64() float64

Float64 returns the floating-point equivalent to this fixed-point value.

func (Fixed) Int64

func (fxd Fixed) Int64() int64

Int64 returns the truncated equivalent integer to this fixed-point value.

func (Fixed) MarshalText

func (fxd Fixed) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Fixed) Mul

func (fxd Fixed) Mul(value Fixed) Fixed

Mul multiplies this value by the passed-in value, returning a new fixed-point value.

func (Fixed) String

func (fxd Fixed) String() string

func (Fixed) Trunc

func (fxd Fixed) Trunc() Fixed

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*Fixed) UnmarshalText

func (fxd *Fixed) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

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