Documentation
¶
Overview ¶
(TOC) This package provides number-related functions and some generic numeric types.
Index ¶
- Variables
- func Clamp[N Number](minimum, value, maximum N) N
- func Commas[I Integer](i I) string
- func IsClose(a, b float64) bool
- func IsZero(x float64) bool
- func MustStrToInt(s string) int
- func RoundToNearest(f float64, nearestTo int) float64
- func StrToInt(s string, default_ int) int
- type Comparable
- type Integer
- type Number
- type SignedNumber
Constants ¶
This section is empty.
Variables ¶
View Source
var Version string
Functions ¶
func Clamp ¶ added in v1.0.1
func Clamp[N Number](minimum, value, maximum N) N
Clamp returns minimum if that's bigger than value; maximum if that's smaller than value; or value if it is in range [minimum, maximum]
func IsClose ¶
IsClose returns true if a and b are very close to each other. Should be adequate for test comparisons. See also IsZero. tag::IsClose[]
func IsZero ¶
IsZero returns true if x is close to 0. Should be adequate for test comparisons. See also IsClose. tag::IsZero[]
func MustStrToInt ¶
func RoundToNearest ¶
Types ¶
type Comparable ¶
type Comparable interface {
~string | ~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
Comparable allows only string or integer map keys or set elements.
Click to show internal directories.
Click to hide internal directories.