Documentation
¶
Overview ¶
Package mathutil provides some additional math methods
Index ¶
- func Abs[N NumericNeg](val N) N
- func B[N Numeric](cond bool, positive, negative N) N
- func Between[N Numeric](val, min, max N) N
- func FromPerc(perc float64, total float64) float64
- func IsFloat(s string) bool
- func IsInt(s string) bool
- func IsNumber(s string) bool
- func Max[N Numeric](val1, val2 N) N
- func Min[N Numeric](val1, val2 N) N
- func Perc[N Numeric](current, total N) float64
- func Round(v float64, p int) float64
- type Float
- type Integer
- type Numeric
- type NumericNeg
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Between ¶
func Between[N Numeric](val, min, max N) N
Between returns value between min and max values
Example ¶
Output: 5 1 4
func IsFloat ¶ added in v13.5.0
IsFloat returns true if given string contains float symbols.
Note that this method does not validate the given value.
Example ¶
Output: false true true
func IsInt ¶ added in v13.5.0
IsInt returns true if given string contains int symbols.
Note that this method does not validate the given value.
Example ¶
Output: false true true
func IsNumber ¶ added in v13.5.0
IsNumber returns true if given string contains number symbols (int or float).
Note that this method does not validate the given value.
Example ¶
Output: false true true
Types ¶
Click to show internal directories.
Click to hide internal directories.