go 函数

package main

import (
"fmt"
"math"
)

func main() {
/*
math包:
*/
i := -100
fmt.Println(math.Abs(float64(i))) //绝对值
fmt.Println(math.Ceil(5.0)) //向上取整
fmt.Println(math.Floor(5.8)) //向下取整
fmt.Println(math.Mod(11, 3)) //取余数,同11%3
fmt.Println(math.Modf(5.26)) //取整数,取小数
fmt.Println(math.Pow(3, 2)) //x的y次方
fmt.Println(math.Pow10(4)) // 10的n次方
fmt.Println(math.Sqrt(8)) //开平方
fmt.Println(math.Cbrt(8)) //开立方
fmt.Println(math.Pi)
}

posted @ 2019-04-03 23:05  liubiaos  阅读(114)  评论(0编辑  收藏  举报