numeric

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFromPtr

func ExtractFromPtr[T ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uint | ~float32 | ~float64](p *T) T

ExtractFromPtr provides null-safe value extraction from pointer.

func Join added in v0.12.0

func Join[T Number](items []T, sep string) string

Join concatenates numeric values into a string with specified separator.

func MustParseFloat64 added in v0.9.0

func MustParseFloat64(s string) float64

MustParseFloat64 enforces strict float64 conversion

func MustParseUint64 added in v0.9.0

func MustParseUint64(s string) uint64

MustParseUint64 performs null-safe string to uint64 conversion

func ParseFloat64 added in v0.9.0

func ParseFloat64(s string, defVal float64) float64

ParseFloat64 implements fault-tolerant float conversion

func ParseUint64 added in v0.9.0

func ParseUint64(s string, defVal uint64) uint64

ParseUint64 provides safe conversion with fallback value

func PositiveToPtr

func PositiveToPtr[T ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uint | ~float32 | ~float64](v T) *T

PositiveToPtr returns a pointer to v if it's greater than zero, otherwise returns nil.

func PositiveUint8ToUint32Ptr added in v0.9.0

func PositiveUint8ToUint32Ptr(v uint8) *uint32

PositiveUint8ToUint32Ptr converts uint8 to uint32 pointer with null-safety.

Types

type Number

type Number interface {
	~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uint | ~int8 | ~int16 | ~int32 | ~int64 | ~int | ~float32 | ~float64
}

Jump to

Keyboard shortcuts

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