Documentation ¶
Index ¶
- Variables
- type Int
- func (f Int) Abs() Int
- func (f Int) Add(value Int) Int
- func (f Int) AsFloat32() float32
- func (f Int) AsFloat64() float64
- func (f Int) AsInt() int
- func (f Int) AsInt64() int64
- func (f Int) Ceil() Int
- func (f Int) Cmp(n Int) int
- func (f Int) Comma() string
- func (f Int) CommaWithSign() string
- func (f Int) Dec() Int
- func (f Int) Div(value Int) Int
- func (f Int) Equal(n Int) bool
- func (f Int) Float32() (float32, error)
- func (f Int) Float64() (float64, error)
- func (f *Int) FromFloat32(value float32) Int
- func (f *Int) FromFloat64(value float64) Int
- func (f *Int) FromInt(value int) Int
- func (f *Int) FromInt64(value int64) Int
- func (f *Int) FromString(str string) (Int, error)
- func (f Int) GreaterThan(n Int) bool
- func (f Int) GreaterThanOrEqual(n Int) bool
- func (f Int) Inc() Int
- func (f Int) Int() (int, error)
- func (f Int) Int64() (int64, error)
- func (f Int) LessThan(n Int) bool
- func (f Int) LessThanOrEqual(n Int) bool
- func (f Int) MarshalJSON() ([]byte, error)
- func (f Int) MarshalText() ([]byte, error)
- func (f Int) MarshalYAML() (interface{}, error)
- func (f Int) Max(value Int) Int
- func (f Int) Min(value Int) Int
- func (f Int) Mod(value Int) Int
- func (f Int) Mul(value Int) Int
- func (f Int) Neg() Int
- func (f Int) Round() Int
- func (f Int) String() string
- func (f Int) StringWithSign() string
- func (f Int) Sub(value Int) Int
- func (f Int) Trunc() Int
- func (f *Int) UnmarshalJSON(in []byte) error
- func (f *Int) UnmarshalText(text []byte) error
- func (f *Int) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
var ( // Max holds the maximum value. Max = Int{/* contains filtered or unexported fields */} // Min holds the minimum value. Min = Int{/* contains filtered or unexported fields */} )
var ( One = FromInt(1) Half = FromStringForced("0.5") NegHalf = Half.Neg() )
Some commonly used values.
Functions ¶
This section is empty.
Types ¶
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int holds a fixed-point value that contains up to 11 decimal places. Values are truncated, not rounded.
func FromFloat32 ¶
FromFloat32 creates a new value from a float32.
func FromFloat64 ¶
FromFloat64 creates a new value from a float64.
func FromString ¶
FromString creates a new value from a string.
func FromStringForced ¶
FromStringForced creates a new value from a string.
func (Int) Comma ¶
Comma returns the same as String(), but with commas for values of 1000 and greater.
func (Int) CommaWithSign ¶
CommaWithSign returns the same as Comma(), but prefixes the value with a '+' if it is positive.
func (Int) Float32 ¶
Float32 is the same as AsFloat32(), except that it returns an error if the value cannot be represented exactly with a float32.
func (Int) Float64 ¶
Float64 is the same as AsFloat64(), except that it returns an error if the value cannot be represented exactly with a float64.
func (*Int) FromFloat32 ¶ added in v1.68.1
FromFloat32 creates a new value from a float32. Here as a convenience for the eval package.
func (*Int) FromFloat64 ¶ added in v1.68.1
FromFloat64 creates a new value from a float64. Here as a convenience for the eval package.
func (*Int) FromInt ¶ added in v1.68.1
FromInt creates a new value from an int. Here as a convenience for the eval package.
func (*Int) FromInt64 ¶ added in v1.68.1
FromInt64 creates a new value from an int64. Here as a convenience for the eval package.
func (*Int) FromString ¶ added in v1.68.1
FromString creates a new value from a string. Here as a convenience for the eval package.
func (Int) GreaterThanOrEqual ¶
GreaterThanOrEqual returns true if i >= n.
func (Int) Int ¶
Int is the same as AsInt(), except that it returns an error if the value cannot be represented exactly with an int.
func (Int) Int64 ¶
Int64 is the same as AsInt64(), except that it returns an error if the value cannot be represented exactly with an int64.
func (Int) LessThanOrEqual ¶
LessThanOrEqual returns true if i <= n.
func (Int) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Int) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (Int) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (Int) Mod ¶
Mod returns the remainder after subtracting all full multiples of the passed-in value.
func (Int) StringWithSign ¶
StringWithSign returns the same as String(), but prefixes the value with a '+' if it is positive.
func (Int) Trunc ¶
Trunc returns a new value which has everything to the right of the decimal place truncated.
func (*Int) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Int) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (*Int) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.