Cookies management by TermsFeed Cookie Consent

🍩 Get Pi constant in Go

shorts numbers math

Help us grow this site 🚀. Disable your ad blocker to see non-intrusive ads

To get the value of the Pi (π) constant in Go, use the mathematical constant math.Pi from the standard library math package.

package main

import (
    "fmt"
    "math"
)

func main() {
    fmt.Printf("%.48f", math.Pi)
}

Output:

3.141592653589793115997963468544185161590576171875

Thank you for being on our site 😊. If you like our tutorials and examples, please consider supporting us with a cup of coffee and we'll turn it into more great Go examples.

Have a great day!

Buy Me A Coffee

🧊 Cube root in Go

shorts numbers math

🟦 Square root in Go

shorts numbers math

🍰 The maximum and minimum value of the int types in Go

shorts numbers math