Documentation ¶
Overview ¶
Package mathutil provides some additional math methods
Index ¶
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 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.