f64d6

package
v1.69.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Max holds the maximum value.
	Max = Int(1<<63 - 1)
	// Min holds the minimum value.
	Min = Int(^(1<<63 - 1))
)

Variables

View Source
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 6 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

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) 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) 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) 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) 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) 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) 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) 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