mathx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package mathx provides focused math and probability helpers.

New code should import this package instead of the legacy mathutils path:

import "github.com/InsideGallery/core/mathx"

Compatibility: github.com/InsideGallery/core/mathutils remains available for existing consumers. Keep new math helpers in mathx so applications can migrate away from the legacy aggregate path without changing behavior.

Index

Constants

View Source
const DefaultPrecision = mathutils.DefaultPrecision

DefaultPrecision is the fallback precision used by RoundWithPrecision.

Variables

This section is empty.

Functions

func ApproximatelyEqual

func ApproximatelyEqual(a, b float64) bool

ApproximatelyEqual reports whether two floats are nearly equal.

func BigIntToHighAndLow

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

BigIntToHighAndLow splits a big integer into high and low uint64 halves.

func CantorPair

func CantorPair(k1, k2 uint64) uint64

CantorPair pairs two uint64 values with the Cantor pairing function.

func CantorUnpair

func CantorUnpair(pair uint64) (uint64, uint64)

CantorUnpair splits a Cantor-paired uint64 into two values.

func Clamp

func Clamp(value, lowerLimit, upperLimit float64) float64

Clamp constrains value to the inclusive lower and upper limits.

func HighAndLowToBigInt

func HighAndLowToBigInt(high, low uint64) *big.Int

HighAndLowToBigInt joins high and low uint64 halves into a big integer.

func IntStringToBigInt

func IntStringToBigInt(str string) *big.Int

IntStringToBigInt parses a base-10 integer string.

func RandomDigitString

func RandomDigitString(length int) string

RandomDigitString returns a random byte string with the requested length.

func Round

func Round(value, precision float64) float64

Round truncates a float to a precision multiplier.

func RoundWithPrecision

func RoundWithPrecision(value, precision float64) float64

RoundWithPrecision rounds a float using the requested precision.

func WeightIndex

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

WeightIndex returns a weighted random key from the probability map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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