Documentation ¶
Index ¶
- Constants
- Variables
- type Int
- func (f Int) Abs() 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) Comma() string
- func (f Int) CommaWithSign() string
- func (f Int) Dec() Int
- func (f Int) Div(value Int) Int
- 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) Inc() Int
- func (f Int) Int() (int, error)
- func (f Int) Int64() (int64, error)
- 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) Round() Int
- func (f Int) String() string
- func (f Int) StringWithSign() string
- 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 ¶
const ( // Max holds the maximum value. Max = Int(1<<63 - 1) // Min holds the minimum value. Min = Int(^(1<<63 - 1)) )
Variables ¶
var ( One = Int(multiplier) Half = Int(multiplier / 2) NegHalf = -Half )
Some commonly used values.
Functions ¶
This section is empty.
Types ¶
type Int ¶
type Int int64
Int holds a fixed-point value that contains up to 1 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 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) 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) 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.