Added NthRoot{,64} methods.
This commit is contained in:
parent
9215311802
commit
29de09a237
10
ints/math.go
10
ints/math.go
@ -72,6 +72,16 @@ func Norm64(i int64) int64 {
|
|||||||
return 0
|
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.
|
// SubAbs subtracts a from b and returns the absolute value of the result.
|
||||||
func SubAbs(a, b int) int {
|
func SubAbs(a, b int) int {
|
||||||
if a > b {
|
if a > b {
|
||||||
|
Loading…
Reference in New Issue
Block a user