Logarithms are used in scientific applications as well as in data visualizations and measurements. The built-in math package contains the commonly used bases of the logarithm. Using these, you are able to get all bases.
Taking logarithms
How to do it...
- Open the console and create the folder chapter03/recipe11.
- Navigate to the directory.
- Create the log.go file with the following content:
package main
import (
"fmt"
"math"
)
func main() {
ln := math.Log(math.E)
fmt.Printf("Ln(E) = %.4f\n", ln)
log10 := math.Log10(-100)
fmt.Printf("Log10(10) = %.4f\n", log10)
log2 := math.Log2(2)
fmt...