1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
package math
import "math"
// Round returns round of float64
func Round(f float64, n int) float64 {
pow10N := math.Pow10(n)
return math.Trunc((f+0.5/pow10N)*pow10N) / pow10N
}
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1
func MinInts(a int, vals ...int) int {
min := a
for _, v := range vals {
if v < min {
min = v
}
}
return min
}
func MaxInts(a int, vals ...int) int {
max := a
for _, v := range vals {
if v > max {
max = v
}
}
return max
}
|