Math

The math module exposes Go's math package: common functions and the constants e, pi, and phi.

fmt := import("fmt")
math := import("math")
fmt.println(math.pi)
fmt.println(math.e)
fmt.println(math.abs(-7.5))
fmt.println(math.sqrt(144.0))
fmt.println(math.pow(2.0, 10.0))
fmt.println(math.floor(3.7))
fmt.println(math.ceil(3.2))
fmt.println(math.min(4.0, 7.0))
fmt.println(math.max(4.0, 7.0))

try it

3.141592653589793
2.718281828459045
7.5
12
1024
3
4
4
7
loading…