Welcome To Golang By Example

Menu
  • Home
  • Blog
  • Contact Us
  • Support this website
Menu

Pi value in Go (Golang)

Posted on March 26, 2020March 26, 2020 by admin

Table of Contents

  • Overview
  • Code:

Overview

math package of GO provides a Pi constant.


This is how it is defined in the constant.go file of math package. It is a float64 value

Pi  = 3.14159265358979323846264338327950288419716939937510582097494459

Code:

package main

import (
	"fmt"
	"math"
)

func main() {
	pi := math.Pi
	fmt.Println(pi)
}

Output:

3.141592653589793
  • golang
  • math
  • pi
  • Follow @golangbyexample

    Popular Articles

    Golang Comprehensive Tutorial Series

    All Design Patterns in Go (Golang)

    Slice in golang

    Variables in Go (Golang) – Complete Guide

    OOP: Inheritance in GOLANG complete guide

    Using Context Package in GO (Golang) – Complete Guide

    All data types in Golang with examples

    Understanding time and date in Go (Golang) – Complete Guide

    ©2025 Welcome To Golang By Example | Design: Newspaperly WordPress Theme