Added NthRoot{,64} methods.

This commit is contained in:
Sander Schobers 2021-02-12 09:43:10 +01:00
parent 9215311802
commit 29de09a237

View File

@ -72,6 +72,16 @@ func Norm64(i int64) int64 {
return 0
}
// NthRoot returns the nth root of i.
func NthRoot(i, n int) int {
return int(math.Pow(float64(i), 1/float64(n)))
}
// NthRoot64 returns the nth root of i.
func NthRoot64(i, n int64) int64 {
return int64(math.Pow(float64(i), 1/float64(n)))
}
// SubAbs subtracts a from b and returns the absolute value of the result.
func SubAbs(a, b int) int {
if a > b {