mathutils

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultPrecision float64 = 0.0001
)

mathematics constants

Variables

This section is empty.

Functions

func ApproximatelyEqual

func ApproximatelyEqual(a, b float64) bool

ApproximatelyEqual function to test if two real numbers are (almost) equal

func BigIntToHighAndLow

func BigIntToHighAndLow(x *big.Int) (uint64, uint64)

func CantorPair

func CantorPair(k1, k2 uint64) uint64

CantorPair two uint64 numbers by cantor pairing function.

func CantorUnpair

func CantorUnpair(pair uint64) (uint64, uint64)

CantorUnpair one uint64 pair to two uint64 numbers by cantor pairing function.

func Clamp

func Clamp(value, lowerLimit, upperLimit float64) float64

Clamp return the result of the "value" clamped by

func HighAndLowToBigInt

func HighAndLowToBigInt(h, l uint64) *big.Int

func IntStringToBigInt

func IntStringToBigInt(str string) *big.Int

func RandomDigitString

func RandomDigitString(length int) (result string)

RandomDigitString return random digit string

func Round

func Round(v float64, p float64) float64

Round float to precision

func RoundWithPrecision

func RoundWithPrecision(value float64, precision float64) float64

RoundWithPrecision round precision

func WeightIndex

func WeightIndex(prob map[interface{}]uint64) interface{}

WeightIndex get key by probability chances

Types

This section is empty.

Jump to

Keyboard shortcuts

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