- Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
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:
x = 2 print(x**2)Translates to
// package decl and imports elided func main() { x := 2 // int fmt.Println(math.Pow(x, 2)) }Which fails to compile with error: ./foo.go:10: cannot use x (type int) as type float64 in argument to math.Pow
Metadata
Metadata
Assignees
Labels
No labels