Added two missing int64 methods (Abs64 and SubAbs64).

This commit is contained in:
Sander Schobers 2020-06-07 08:44:34 +02:00
parent 82f27a2b4a
commit 9215311802

View File

@ -10,6 +10,14 @@ func Abs(i int) int {
return i return i
} }
// Abs64 returns the absolute value of i.
func Abs64(i int64) int64 {
if 0 > i {
return -i
}
return i
}
// Min returns the minimum of a and b. // Min returns the minimum of a and b.
func Min(a, b int) int { func Min(a, b int) int {
if a < b { if a < b {
@ -72,6 +80,14 @@ func SubAbs(a, b int) int {
return b - a return b - a
} }
// SubAbs64 subtracts a from b and returns the absolute value of the result.
func SubAbs64(a, b int64) int64 {
if a > b {
return a - b
}
return b - a
}
// Pow returns the power of base b to the exponent e. // Pow returns the power of base b to the exponent e.
func Pow(b, e int) int { func Pow(b, e int) int {
if 0 == e { if 0 == e {