Documentation ¶
Index ¶
- func As[T fixed.Dx, TO xmath.Numeric](f Int[T]) TO
- func CheckedAs[T fixed.Dx, TO xmath.Numeric](f Int[T]) (TO, error)
- func MaxDecimalDigits[T fixed.Dx]() int
- type Fraction
- type Int
- func From[T fixed.Dx, FROM xmath.Numeric](value FROM) Int[T]
- func FromString[T fixed.Dx](str string) (Int[T], error)
- func FromStringForced[T fixed.Dx](str string) Int[T]
- func MaxSafeMultiply[T fixed.Dx]() Int[T]
- func Maximum[T fixed.Dx]() Int[T]
- func Minimum[T fixed.Dx]() Int[T]
- func Multiplier[T fixed.Dx]() Int[T]
- func (f Int[T]) Abs() Int[T]
- func (f Int[T]) Add(value Int[T]) Int[T]
- func (f Int[T]) Ceil() Int[T]
- func (f Int[T]) Cmp(n Int[T]) int
- func (f Int[T]) Comma() string
- func (f Int[T]) CommaWithSign() string
- func (f Int[T]) Dec() Int[T]
- func (f Int[T]) Div(value Int[T]) Int[T]
- func (f Int[T]) Equal(n Int[T]) bool
- func (f Int[T]) GreaterThan(n Int[T]) bool
- func (f Int[T]) GreaterThanOrEqual(n Int[T]) bool
- func (f Int[T]) Inc() Int[T]
- func (f Int[T]) LessThan(n Int[T]) bool
- func (f Int[T]) LessThanOrEqual(n Int[T]) bool
- func (f Int[T]) MarshalJSON() ([]byte, error)
- func (f Int[T]) MarshalText() ([]byte, error)
- func (f Int[T]) MarshalYAML() (interface{}, error)
- func (f Int[T]) Max(value Int[T]) Int[T]
- func (f Int[T]) Min(value Int[T]) Int[T]
- func (f Int[T]) Mod(value Int[T]) Int[T]
- func (f Int[T]) Mul(value Int[T]) Int[T]
- func (f Int[T]) Neg() Int[T]
- func (f Int[T]) Round() Int[T]
- func (f Int[T]) String() string
- func (f Int[T]) StringWithSign() string
- func (f Int[T]) Sub(value Int[T]) Int[T]
- func (f Int[T]) Trunc() Int[T]
- func (f *Int[T]) UnmarshalJSON(in []byte) error
- func (f *Int[T]) UnmarshalText(text []byte) error
- func (f *Int[T]) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckedAs ¶
CheckedAs is the same as As(), except that it returns an error if the value cannot be represented exactly in the requested destination type.
func MaxDecimalDigits ¶
MaxDecimalDigits returns the maximum number of digits after the decimal that will be used.
Types ¶
type Fraction ¶ added in v1.71.0
Fraction holds a fractional value.
func NewFraction ¶ added in v1.71.0
NewFraction creates a new fractional value from a string.
func (Fraction[T]) MarshalJSON ¶ added in v1.71.0
MarshalJSON implements json.Marshaler.
func (*Fraction[T]) Normalize ¶ added in v1.71.0
func (f *Fraction[T]) Normalize()
Normalize the fraction, eliminating any division by zero and ensuring a positive denominator.
func (Fraction[T]) StringWithSign ¶ added in v1.71.0
StringWithSign returns the same as String(), but prefixes the value with a '+' if it is positive.
func (*Fraction[T]) UnmarshalJSON ¶ added in v1.71.0
UnmarshalJSON implements json.Unmarshaler.
type Int ¶
Int holds a fixed-point value. Values are truncated, not rounded.
func FromString ¶
FromString creates a new value from a string.
func FromStringForced ¶
FromStringForced creates a new value from a string.
func MaxSafeMultiply ¶
MaxSafeMultiply returns the maximum value that can be safely multiplied without overflow.
func (Int[T]) Comma ¶
Comma returns the same as String(), but with commas for values of 1000 and greater.
func (Int[T]) CommaWithSign ¶
CommaWithSign returns the same as Comma(), but prefixes the value with a '+' if it is positive.
func (Int[T]) GreaterThan ¶
GreaterThan returns true if i > n.
func (Int[T]) GreaterThanOrEqual ¶
GreaterThanOrEqual returns true if i >= n.
func (Int[T]) LessThanOrEqual ¶
LessThanOrEqual returns true if i <= n.
func (Int[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Int[T]) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (Int[T]) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (Int[T]) Mod ¶
Mod returns the remainder after subtracting all full multiples of the passed-in value.
func (Int[T]) StringWithSign ¶
StringWithSign returns the same as String(), but prefixes the value with a '+' if it is positive.
func (Int[T]) Trunc ¶
Trunc returns a new value which has everything to the right of the decimal place truncated.
func (*Int[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Int[T]) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (*Int[T]) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.