向上取整
package main
import(
"fmt"
"math"
)
func main() {
a := 123.23
b := math.Ceil(a)
fmt.Println(b)
}
输出:124
向下取整
package main
import(
"fmt"
"math"
)
func main() {
a := 123.23
b := math.Floor(a)
fmt.Println(b)
}
输出:123
向上取整
package main
import(
"fmt"
"math"
)
func main() {
a := 123.23
b := math.Ceil(a)
fmt.Println(b)
}
输出:124
向下取整
package main
import(
"fmt"
"math"
)
func main() {
a := 123.23
b := math.Floor(a)
fmt.Println(b)
}
输出:123