Documentation ¶
Overview ¶
Package fixedn implements fixed point integers with arbitrary precision.
Index ¶
- Variables
- func FromString(s string, precision int) (*big.Int, error)
- func ToString(bi *big.Int, precision int) string
- type Fixed8
- func (f Fixed8) Add(g Fixed8) Fixed8
- func (f Fixed8) CompareTo(g Fixed8) int
- func (f *Fixed8) DecodeBinary(r *io.BinReader)
- func (f Fixed8) Div(i int64) Fixed8
- func (f *Fixed8) EncodeBinary(w *io.BinWriter)
- func (f Fixed8) Equal(g Fixed8) bool
- func (f Fixed8) FloatValue() float64
- func (f Fixed8) FractionalValue() int32
- func (f Fixed8) GreaterThan(g Fixed8) bool
- func (f Fixed8) IntegralValue() int64
- func (f Fixed8) LessThan(g Fixed8) bool
- func (f Fixed8) MarshalJSON() ([]byte, error)
- func (f Fixed8) MarshalYAML() (interface{}, error)
- func (f Fixed8) String() string
- func (f Fixed8) Sub(g Fixed8) Fixed8
- func (f *Fixed8) UnmarshalJSON(data []byte) error
- func (f *Fixed8) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFormat = errors.New("invalid decimal format")
ErrInvalidFormat is returned when decimal format is invalid.
Functions ¶
func FromString ¶
FromString converts string to a big decimal with specified precision.
Types ¶
type Fixed8 ¶
type Fixed8 int64
Fixed8 represents a fixed-point number with precision 10^-8.
func Fixed8FromFloat ¶
Fixed8FromFloat returns a new Fixed8 type multiplied by decimals.
func Fixed8FromInt64 ¶
Fixed8FromInt64 returns a new Fixed8 type multiplied by decimals.
func Fixed8FromString ¶
Fixed8FromString parses s which must be a fixed point number with precision up to 10^-8
func (Fixed8) CompareTo ¶
CompareTo returns the difference between the f and g. difference < 0 implies f < g. difference = 0 implies f = g. difference > 0 implies f > g.
func (*Fixed8) DecodeBinary ¶
DecodeBinary implements the io.Serializable interface.
func (*Fixed8) EncodeBinary ¶
EncodeBinary implements the io.Serializable interface.
func (Fixed8) FloatValue ¶
FloatValue returns the original value representing Fixed8 as float64.
func (Fixed8) FractionalValue ¶
FractionalValue returns decimal part of the original value. It has the same sign as f, so that f = f.IntegralValue() + f.FractionalValue().
func (Fixed8) GreaterThan ¶
GreaterThan implements Fixd8 < operator.
func (Fixed8) IntegralValue ¶
IntegralValue returns integer part of the original value representing Fixed8 as int64.
func (Fixed8) MarshalJSON ¶
MarshalJSON implements the json marshaller interface.
func (Fixed8) MarshalYAML ¶
MarshalYAML implements the yaml marshaller interface.
func (*Fixed8) UnmarshalJSON ¶
UnmarshalJSON implements the json unmarshaller interface.
func (*Fixed8) UnmarshalYAML ¶
UnmarshalYAML implements the yaml unmarshaler interface.