Documentation
¶
Overview ¶
Package math provides safe integer conversions with overflow protection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clamp ¶
Clamp restricts a value to a range [lower, upper]. If v < lower, returns lower. If v > upper, returns upper. Otherwise, returns v.
func MustSafeIntToUint32 ¶
MustSafeIntToUint32 invokes SafeIntToUint32 and panics if an error is returned.
func MustSafeUint64ToInt64 ¶
MustSafeUint64ToInt64 invokes SafeUint64ToInt64 and panics if an error is returned.
func SafeAddUint64Ptr ¶
SafeAddUint64Ptr adds the values to the counter pointer, and returns an error if the counter would overflow.
func SafeIntToUint32 ¶
SafeIntToUint32 converts an int to a uint32, returning an error if the value is negative or exceeds the maximum uint32 value.
func SafeUint64ToInt64 ¶
SafeUint64ToInt64 converts a uint64 to an int64, returning an error if the value is too large to fit in an int64.
Types ¶
This section is empty.