decimal

package
v0.26.0-victorialogs Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StaleNaN = math.Float64frombits(staleNaNBits)

StaleNaN is a special NaN value, which is used as Prometheus staleness mark. See https://www.robustperception.io/staleness-and-promql

Functions

func AppendDecimalToFloat

func AppendDecimalToFloat(dst []float64, va []int64, e int16) []float64

AppendDecimalToFloat converts each item in va to f=v*10^e, appends it to dst and returns the resulting dst.

func AppendFloatToDecimal

func AppendFloatToDecimal(dst []int64, src []float64) ([]int64, int16)

AppendFloatToDecimal converts each item in src to v*10^e and appends each v to dst returning it as va.

It tries minimizing each item in dst.

func CalibrateScale

func CalibrateScale(a []int64, ae int16, b []int64, be int16) (e int16)

CalibrateScale calibrates a and b with the corresponding exponents ae, be and returns the resulting exponent e.

func ExtendFloat64sCapacity

func ExtendFloat64sCapacity(dst []float64, additionalItems int) []float64

ExtendFloat64sCapacity extends dst capacity to hold additionalItems and returns the extended dst.

func ExtendInt64sCapacity

func ExtendInt64sCapacity(dst []int64, additionalItems int) []int64

ExtendInt64sCapacity extends dst capacity to hold additionalItems and returns the extended dst.

func FromFloat

func FromFloat(f float64) (int64, int16)

FromFloat converts f to v*10^e.

It tries minimizing v. For instance, for f = -1.234 it returns v = -1234, e = -3.

FromFloat doesn't work properly with NaN values other than Prometheus staleness mark, so don't pass them here.

func IsStaleNaN added in v1.64.0

func IsStaleNaN(f float64) bool

IsStaleNaN returns true if f represents Prometheus staleness mark.

func RoundToDecimalDigits added in v1.53.0

func RoundToDecimalDigits(f float64, digits int) float64

RoundToDecimalDigits rounds f to the given number of decimal digits after the point.

See also RoundToSignificantFigures.

func RoundToSignificantFigures added in v1.53.0

func RoundToSignificantFigures(f float64, digits int) float64

RoundToSignificantFigures rounds f to value with the given number of significant figures.

See also RoundToDecimalDigits.

func ToFloat

func ToFloat(v int64, e int16) float64

ToFloat returns f=v*10^e.

Types

This section is empty.

Jump to

Keyboard shortcuts

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