Menu Close

Go – How to get Pi value in go

Here, we will learn how to get Pi value in go. We can use Pi constant of math package to get Pi value in go.

Constant value:

Pi  = 3.14159265358979323846264338327950288419716939937510582097494459 

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  pi_val := math.Pi

  fmt.Println("Pi value: ", pi_val)

}

Output:

$ go run sample.go
Pi value:  3.141592653589793

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, math

Leave a Reply

Your email address will not be published. Required fields are marked *