Skip to content

Commit 4de4240

Browse files
committed
Update Pow
1 parent 40bd712 commit 4de4240

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

math/number/pow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ func Ldexp(a, b int) float64 {
88
}
99

1010
// Pow returns a**r, the base-a exponential of r.
11-
func Pow(a, r int) int {
11+
func Pow[T ~int | ~int64](a, r T) T {
1212
if a == 0 {
1313
return 0
1414
}
@@ -18,7 +18,7 @@ func Pow(a, r int) int {
1818
}
1919

2020
// exponentiation by squaring
21-
p := 1
21+
p := T(1)
2222
for r > 0 {
2323
if r&1 == 1 {
2424
p = p * a

0 commit comments

Comments
 (0)