Documentation ¶
Overview ¶
Package mathutil provides some additional math methods
Index ¶
- func Abs[N NumericNeg](val N) N
- func Abs16(val int16) int16deprecated
- func Abs32(val int32) int32deprecated
- func Abs64(val int64) int64deprecated
- func Abs8(val int8) int8deprecated
- func AbsF(val float64) float64deprecated
- func AbsF32(val float32) float32deprecated
- func AbsF64(val float64) float64deprecated
- func Between[N Numeric](val, min, max N) N
- func Between16(val, min, max int16) int16deprecated
- func Between32(val, min, max int32) int32deprecated
- func Between64(val, min, max int64) int64deprecated
- func Between8(val, min, max int8) int8deprecated
- func BetweenF(val, min, max float64) float64deprecated
- func BetweenF32(val, min, max float32) float32deprecated
- func BetweenF64(val, min, max float64) float64deprecated
- func BetweenU(val, min, max uint) uintdeprecated
- func BetweenU16(val, min, max uint16) uint16deprecated
- func BetweenU32(val, min, max uint32) uint32deprecated
- func BetweenU64(val, min, max uint64) uint64deprecated
- func BetweenU8(val, min, max uint8) uint8deprecated
- func Max[N Numeric](val1, val2 N) N
- func Max16(val1, val2 int16) int16deprecated
- func Max32(val1, val2 int32) int32deprecated
- func Max64(val1, val2 int64) int64deprecated
- func Max8(val1, val2 int8) int8deprecated
- func MaxU(val1, val2 uint) uintdeprecated
- func MaxU16(val1, val2 uint16) uint16deprecated
- func MaxU32(val1, val2 uint32) uint32deprecated
- func MaxU64(val1, val2 uint64) uint64deprecated
- func MaxU8(val1, val2 uint8) uint8deprecated
- func Min[N Numeric](val1, val2 N) N
- func Min16(val1, val2 int16) int16deprecated
- func Min32(val1, val2 int32) int32deprecated
- func Min64(val1, val2 int64) int64deprecated
- func Min8(val1, val2 int8) int8deprecated
- func MinU(val1, val2 uint) uintdeprecated
- func MinU16(val1, val2 uint16) uint16deprecated
- func MinU32(val1, val2 uint32) uint32deprecated
- func MinU64(val1, val2 uint64) uint64
- func MinU8(val1, val2 uint8) uint8deprecated
- func Perc[N Numeric](val1, val2 N) float64
- func Round(v float64, p int) float64
- type Numeric
- type NumericNeg
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[N NumericNeg](val N) N
Abs returns absolute value
Example ¶
fmt.Println(Abs(10)) fmt.Println(Abs(-10))
Output: 10 10
func Between ¶
func Between[N Numeric](val, min, max N) N
Between returns value between min and max values
Example ¶
fmt.Println(Between(10, 1, 5)) fmt.Println(Between(-3, 1, 5)) fmt.Println(Between(4, 1, 5))
Output: 5 1 4
func BetweenF32
deprecated
func BetweenF64
deprecated
func BetweenU16
deprecated
func BetweenU32
deprecated
func BetweenU64
deprecated
func Max ¶
func Max[N Numeric](val1, val2 N) N
Max returns a greater value
Example ¶
fmt.Println(Max(1, 10)) fmt.Println(Max(3, -3))
Output: 10 3
func Min ¶
func Min[N Numeric](val1, val2 N) N
Min returns a smaller value
Example ¶
fmt.Println(Min(1, 10)) fmt.Println(Min(3, -3))
Output: 1 -3
Types ¶
Click to show internal directories.
Click to hide internal directories.