viper-app/pkg/math.go

36 lines
442 B
Go
Raw Normal View History

package pkg
import "math"
func MinInt(a ...int) int {
min := math.MaxInt
for _, i := range a {
if min > i {
min = i
}
}
return min
}
const (
ByteBit = 1 << 3 << iota
_
I32Bit
I64Bit
)
const (
I32Byte = I32Bit / ByteBit
I64Byte = I64Bit / ByteBit
)
func Int64Byte(i64 int64) [I64Byte]byte {
res := [I64Byte]byte{}
for i := 0; i < I64Byte; i++ {
res[I64Byte-1-i] = byte(i64 & 0xff)
i64 >>= ByteBit
}
return res
}