go:stdlib:math
Table of Contents
math package
What is it?
`math` is Go’s standard library package for basic mathematical constants and functions (mostly for `float64`).
What is it used for?
- Common math functions: sqrt, pow, trig functions.
- Math constants like Pi and E.
Examples
r := 2.0 area := math.Pi * r * r // circle area root := math.Sqrt(9) // 3
Common items
- `math.Pi`: value of Pi
- `math.E`: Euler’s number
- `math.Sqrt(x)`: square root
- `math.Pow(x, y)`: power
- `math.Sin/Cos/Tan`: trigonometry
Notes
- `math` works with floating-point numbers (`float64`).
- For random numbers, use `math/rand` (different package).
Hard words (English)
- constant /ˈkɑːnstənt/: hằng số
- square root /skwer ruːt/: căn bậc hai
- trigonometry /ˌtrɪɡəˈnɑːmətri/: lượng giác
- floating-point /ˈfloʊtɪŋ pɔɪnt/: số dấu phẩy động
go/stdlib/math.txt · Last modified: by phong2018
