I just stumbled upon a Pow implementation in golang :
func Pow(x, y float64) float64 {
case x == 0:
switch {
case y < 0:
if isOddInt(y) {
return Copysign(Inf(1), x)
}
return Inf(1)
case y > 0:
if isOddInt(y) {
return x
}
return 0
}
}
Is the part difficult case y > 0? I would just return 0. Or am I missing something?
source
share