Documentation
¶
Index ¶
- Variables
- type ErrFormat
- type ErrNaN
- type ErrParse
- type ErrTooLarge
- type Fixed
- func (f Fixed) Abs() *Fixed
- func (f Fixed) Add(f0 Fixed) *Fixed
- func (f Fixed) Cmp(f0 *Fixed) int
- func (f Fixed) Div(f0 Fixed) *Fixed
- func (f Fixed) Equal(f0 *Fixed) bool
- func (f Fixed) Float() float64
- func (f Fixed) Frac() float64
- func (f Fixed) GreaterThan(f0 *Fixed) bool
- func (f Fixed) GreaterThanOrEqual(f0 *Fixed) bool
- func (f Fixed) Int() int64
- func (f Fixed) IsNaN() bool
- func (f Fixed) IsZero() bool
- func (f Fixed) LessThan(f0 *Fixed) bool
- func (f Fixed) LessThanOrEqual(f0 *Fixed) bool
- func (f Fixed) MarshalBinary() (data []byte, err error)
- func (f Fixed) MarshalJSON() ([]byte, error)
- func (f Fixed) Mul(f0 Fixed) *Fixed
- func (f Fixed) Round(n int) *Fixed
- func (f Fixed) Sign() int64
- func (f Fixed) String() string
- func (f Fixed) StringN(decimals int) string
- func (f Fixed) Sub(f0 Fixed) *Fixed
- func (f *Fixed) UnmarshalBinary(data []byte) error
- func (f *Fixed) UnmarshalJSON(bytes []byte) error
- func (f Fixed) WriteTo(w io.ByteWriter) error
Constants ¶
This section is empty.
Variables ¶
var ( NaN = &Fixed{ nan: &ErrNaN{ reason: errNaNDefault, }, } ZERO = &Fixed{fp: 0} )
Functions ¶
This section is empty.
Types ¶
type ErrParse ¶
type ErrParse struct {
// contains filtered or unexported fields
}
func (ErrParse) MarshalJSON ¶
type ErrTooLarge ¶
type ErrTooLarge string
func (ErrTooLarge) Error ¶
func (e ErrTooLarge) Error() string
type Fixed ¶
type Fixed struct {
// contains filtered or unexported fields
}
Fixed is a fixed precision 38.24 number (supports 11.7 digits). It supports NaN.
func FromInt64 ¶
NewI creates a Fixed for an integer, moving the decimal point n places to the left For example, NewI(123,1) becomes 12.3.
func FromScientific ¶
func MustParse ¶
MustParse creates a new Fixed from a string, and panics if the string could not be parsed
func Parse ¶
Parse creates a new Fixed from a string, returning NaN, and error if the string could not be parsed.
func (Fixed) Cmp ¶
Cmp compares two Fixed. Returns:
if f == f0 : 0 if f > f0 : 0 if f < f0 : -1 if both are NaN : 0. if f is NaN : 1 if f0 is NaN, return -1
func (Fixed) Equal ¶
Equal returns true if the f == f0. If either operand is NaN, false is returned. Use IsNaN() to test for NaN
func (Fixed) GreaterThanOrEqual ¶
GreaterThaOrEqual tests Cmp() for 1 or 0
func (Fixed) LessThanOrEqual ¶
LessThan tests Cmp() for -1 or 0
func (Fixed) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Fixed) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Fixed) Mul ¶
Mul multiplies f by f0 returning a Fixed. If either operand is NaN, NaN is returned
func (Fixed) StringN ¶
StringN converts a Fixed to a String with a specified number of decimal places, truncating as required
func (Fixed) Sub ¶
Sub subtracts f0 from f producing a Fixed. If either operand is NaN, NaN is returned
func (*Fixed) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (*Fixed) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.