lib

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt32

func AbsInt32(i int32) uint32

func BigFloat0

func BigFloat0() *big.Float

BigFloat0 returns a `big.Float` that is set to 0.

func BigFloatMaxUint64

func BigFloatMaxUint64() *big.Float

BigFloatMaxUint64 returns a `big.Float` that is set to MaxUint64.

func BigPow10

func BigPow10(exponent uint64) *big.Int

BigPow10 returns the result of `10^exponent`. Caches all calculated values and re-uses cached values in any following calls to BigPow10.

func ConvertBigFloatSliceToUint64Slice

func ConvertBigFloatSliceToUint64Slice(values []*big.Float) ([]uint64, error)

ConvertBigFloatSliceToUint64Slice attempts to convert all values in a slice from big Float to uint64 and return an error if any conversions fail. Note: during conversion, will always round down.

func ConvertBigFloatToUint64

func ConvertBigFloatToUint64(value *big.Float) (uint64, error)

ConvertBigFloatToUint64 attempts to convert a big Float into a uint64 and returns an error if the conversion would fail. Note: during conversion, will always round down.

func ConvertStringSliceToBigFloatSlice

func ConvertStringSliceToBigFloatSlice(values []string) ([]*big.Float, error)

ConvertStringSliceToBigFloatSlice attempts to convert all values in a slice from string to big Float and return an error if any conversions fail.

func GetSortedKeys

func GetSortedKeys[R interface {
	~[]K
	sort.Interface
}, K comparable, V any](m map[K]V) []K

GetSortedKeys returns the keys of the map in sorted order.

func Median

func Median[V uint64 | uint32 | int64 | int32](input []V) (V, error)

Median is a generic median calculator. If the input has an even number of elements, then the average of the two middle numbers is rounded away from zero.

func Min

func Min[T constraints.Ordered](x, y T) T

Types

type Sortable

type Sortable[K constraints.Ordered] []K

Sortable[K] attaches the methods of sort.Interface to []K, sorting in increasing order.

func (Sortable[K]) Len

func (s Sortable[K]) Len() int

func (Sortable[K]) Less

func (s Sortable[K]) Less(i, j int) bool

func (Sortable[K]) Swap

func (s Sortable[K]) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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