You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python's pow operator (x**2) produces math.Pow(x, 2) in Go; however, in Go, math.Pow() only accepts floats, but in Python, ** handles ints as well as floats. This means the Python program:
I would inline int(math.Pow(float64(a), float64(b)), or a custom PowInt() if math.Pow() isn't very performant for integers. I would use bigint if I was concerned about overflow. I'm not sure how you generalize this for all applications--maybe you just always use bigint and take the perf hit in all cases?
Python's pow operator (
x**2
) producesmath.Pow(x, 2)
in Go; however, in Go,math.Pow()
only accepts floats, but in Python,**
handles ints as well as floats. This means the Python program:Translates to
Which fails to compile with error:
./foo.go:10: cannot use x (type int) as type float64 in argument to math.Pow
The text was updated successfully, but these errors were encountered: