As described in previous recipes, the representation of the floating-point numbers also complicates the arithmetic. For general purposes, the operations on the built-in float64 are sufficient. In case more precision is needed, the math/big package comes into play. This recipe will show you how to handle this.
Floating-point arithmetics
How to do it...
- Open the console and create the folder chapter03/recipe04.
- Navigate to the directory.
- Create the main.go file with the following content:
package main
import (
"fmt"
"math/big"
)
const PI = `3.1415926535897932384626433832795028841971693
993751058209749445923078164062862089986280348253
...