package main
import (
"fmt"
"math"
"math/big"
)
const PI = `3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196`
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 = %.100f\n", circumference)
fmt.Printf("Circumference float64 = %.100f\n", pi64*diameter)
sum := new(big.Float).Add(pi, pi)
fmt.Printf("Sum = %.100f\n", sum)
diff := new(big.Float).Sub(pi, pi)
fmt.Printf("Diff = %.100f\n", diff)
quo := new(big.Float).Quo(pi, pi)
fmt.Printf("Quocient = %.100f\n", quo)
}
// Round returns the nearest integer.
func Round(x float64) float64 {
t := math.Trunc(x)
if math.Abs(x-t) >= 0.5 {
return t + math.Copysign(1, x)
}
return t
}
/*
Circumference big.Float = 9.4247779607693797153879301498385086525915081981253174629248337769234492188586269958841044760263512039
Circumference float64 = 9.4247779607693793479938904056325554847717285156250000000000000000000000000000000000000000000000000000
Sum = 6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341360
Diff = 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Quocient = 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
*/