feat: maths 包支持奇偶数判断

This commit is contained in:
kercylan98 2023-07-29 10:55:29 +08:00
parent 997bbbe2bc
commit ac43963a86
1 changed files with 10 additions and 0 deletions

View File

@ -194,3 +194,13 @@ func JoinNumbers[V generic.Number](num1 V, n ...V) V {
}
return v
}
// IsOdd 返回 n 是否为奇数
func IsOdd[V generic.Integer](n V) bool {
return 0 != (int64(n) & 1)
}
// IsEven 返回 n 是否为偶数
func IsEven[V generic.Integer](n V) bool {
return 0 == (int64(n) & 1)
}