math.go 543 B

123456789101112131415161718192021
  1. package math
  2. import (
  3. "fmt"
  4. "math"
  5. )
  6. func main(){
  7. i:=100
  8. fmt.Println(math.Abs(float64(i)))//绝对值
  9. fmt.Println(math.Ceil(5.0)) //向上取整
  10. fmt.Println(math.Floor(5.8)) //向下取整
  11. fmt.Println(math.Mod(11, 3)) //取余数,同11%3
  12. fmt.Println(math.Modf(5.26)) //取整数,取小数
  13. fmt.Println(math.Pow(3, 2)) //x的y次方
  14. fmt.Println(math.Pow10(4)) // 10的n次方
  15. fmt.Println(math.Sqrt(8)) //开平方
  16. fmt.Println(math.Cbrt(8)) //开立方
  17. fmt.Println(math.Pi)
  18. }