f128d3

package
v1.68.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 */}
)
View Source
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 3 decimal places. Values are truncated, not rounded.

func FromFloat32

func FromFloat32(value float32) Int

FromFloat32 creates a new value from a float32.

func FromFloat64

func FromFloat64(value float64) Int

FromFloat64 creates a new value from a float64.

func FromInt

func FromInt(value int) Int

FromInt creates a new value from an int.

func FromInt64

func FromInt64(value int64) Int

FromInt64 creates a new value from an int64.

func FromString

func FromString(str string) (Int, error)

FromString creates a new value from a string.

func FromStringForced

func FromStringForced(str string) Int

FromStringForced creates a new value from a string.

func (Int) Abs

func (f Int) Abs() Int

Abs returns the absolute value of this value.

func (Int) Add

func (f Int) Add(value Int) Int

Add adds this value to the passed-in value, returning a new value.

func (Int) AsFloat32

func (f Int) AsFloat32() float32

AsFloat32 returns the floating-point equivalent to this value.

func (Int) AsFloat64

func (f Int) AsFloat64() float64

AsFloat64 returns the floating-point equivalent to this value.

func (Int) AsInt

func (f Int) AsInt() int

AsInt returns the truncated equivalent integer to this value.

func (Int) AsInt64

func (f Int) AsInt64() int64

AsInt64 returns the truncated equivalent integer to this value.

func (Int) Ceil

func (f Int) Ceil() Int

Ceil returns the value rounded up to the nearest whole number.

func (Int) Cmp

func (f Int) Cmp(n Int) int

Cmp returns 1 if i > n, 0 if i == n, and -1 if i < n.

func (Int) Comma

func (f Int) Comma() string

Comma returns the same as String(), but with commas for values of 1000 and greater.

func (Int) CommaWithSign

func (f Int) CommaWithSign() string

CommaWithSign returns the same as Comma(), but prefixes the value with a '+' if it is positive.

func (Int) Dec added in v1.68.0

func (f Int) Dec() Int

Dec returns the value decremented by 1.

func (Int) Div

func (f Int) Div(value Int) Int

Div divides this value by the passed-in value, returning a new value.

func (Int) Equal

func (f Int) Equal(n Int) bool

Equal returns true if i == n.

func (Int) Float32

func (f Int) Float32() (float32, error)

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

func (f Int) Float64() (float64, error)

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

func (f *Int) FromFloat32(value float32) Int

FromFloat32 creates a new value from a float32. Here as a convenience for the eval package.

func (*Int) FromFloat64 added in v1.68.1

func (f *Int) FromFloat64(value float64) Int

FromFloat64 creates a new value from a float64. Here as a convenience for the eval package.

func (*Int) FromInt added in v1.68.1

func (f *Int) FromInt(value int) Int

FromInt creates a new value from an int. Here as a convenience for the eval package.

func (*Int) FromInt64 added in v1.68.1

func (f *Int) FromInt64(value int64) Int

FromInt64 creates a new value from an int64. Here as a convenience for the eval package.

func (*Int) FromString added in v1.68.1

func (f *Int) FromString(str string) (Int, error)

FromString creates a new value from a string. Here as a convenience for the eval package.

func (Int) GreaterThan

func (f Int) GreaterThan(n Int) bool

GreaterThan returns true if i > n.

func (Int) GreaterThanOrEqual

func (f Int) GreaterThanOrEqual(n Int) bool

GreaterThanOrEqual returns true if i >= n.

func (Int) Inc added in v1.68.0

func (f Int) Inc() Int

Inc returns the value incremented by 1.

func (Int) Int

func (f Int) Int() (int, error)

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

func (f Int) Int64() (int64, error)

Int64 is the same as AsInt64(), except that it returns an error if the value cannot be represented exactly with an int64.

func (Int) LessThan

func (f Int) LessThan(n Int) bool

LessThan returns true if i < n.

func (Int) LessThanOrEqual

func (f Int) LessThanOrEqual(n Int) bool

LessThanOrEqual returns true if i <= n.

func (Int) MarshalJSON

func (f Int) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Int) MarshalText

func (f Int) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Int) MarshalYAML

func (f Int) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (Int) Max

func (f Int) Max(value Int) Int

Max returns the maximum of this value or its argument.

func (Int) Min

func (f Int) Min(value Int) Int

Min returns the minimum of this value or its argument.

func (Int) Mod

func (f Int) Mod(value Int) Int

Mod returns the remainder after subtracting all full multiples of the passed-in value.

func (Int) Mul

func (f Int) Mul(value Int) Int

Mul multiplies this value by the passed-in value, returning a new value.

func (Int) Neg

func (f Int) Neg() Int

Neg negates this value, returning a new value.

func (Int) Round

func (f Int) Round() Int

Round returns the nearest integer, rounding half away from zero.

func (Int) String

func (f Int) String() string

func (Int) StringWithSign

func (f Int) StringWithSign() string

StringWithSign returns the same as String(), but prefixes the value with a '+' if it is positive.

func (Int) Sub

func (f Int) Sub(value Int) Int

Sub subtracts the passed-in value from this value, returning a new value.

func (Int) Trunc

func (f Int) Trunc() Int

Trunc returns a new value which has everything to the right of the decimal place truncated.

func (*Int) UnmarshalJSON

func (f *Int) UnmarshalJSON(in []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Int) UnmarshalText

func (f *Int) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Int) UnmarshalYAML

func (f *Int) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL