mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
35 lines
508 B
Go
35 lines
508 B
Go
// Package math 计算实用工具
|
|
package math
|
|
|
|
// Max 返回两数最大值,该函数将被内联
|
|
func Max(a, b int) int {
|
|
if a > b {
|
|
return a
|
|
}
|
|
return b
|
|
}
|
|
|
|
// Min 返回两数最小值,该函数将被内联
|
|
func Min(a, b int) int {
|
|
if a > b {
|
|
return b
|
|
}
|
|
return a
|
|
}
|
|
|
|
// Abs 返回绝对值,该函数将被内联
|
|
func Abs(x int) int {
|
|
if x < 0 {
|
|
return -x
|
|
}
|
|
return x
|
|
}
|
|
|
|
// Abs64 返回绝对值,该函数将被内联
|
|
func Abs64(x int64) int64 {
|
|
if x < 0 {
|
|
return -x
|
|
}
|
|
return x
|
|
}
|