O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Open the console and create the folder chapter03/recipe04.
  2. Navigate to the directory.
  3. Create the main.go file with the following content:
        package main        import (          "fmt"          "math/big"        )        const PI = `3.1415926535897932384626433832795028841971693                    993751058209749445923078164062862089986280348253                    421170679821480865132823066470938446095505822317                    253594081284811174502841027019385211055596446229                    4895493038196`        const diameter = 3.0        const precision = 400        func main() {          pi, _ := new(big.Float).SetPrec(precision).SetString(PI)          d := new(big.Float).SetPrec(precision).SetFloat64(diameter)          circumference := new(big.Float).Mul(pi, d)           pi64, _ := pi.Float64()          fmt.Printf("Circumference big.Float = %.400f\n",                     circumference) fmt.Printf("Circumference ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required