June 2017
Intermediate to advanced
400 pages
10h 32m
English
The math package makes it possible to do complex mathematical operations in Go. This recipe should be used in conjunction with this package for doing complex floating point operations and converting between types as needed. It's worth noting that even with float64, there may still be rounding errors for certain floating point numbers, and the following recipe demonstrates some techniques for dealing with this.
The math/big section showcases a recursive Fibonacci sequence. If you modify main.go to loop well beyond 10, you'll quickly overflow int64 if it was used instead of big.Int. This package also has helper methods to convert between the big types to other types.
Read now
Unlock full access