You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
236 B
14 lines
236 B
2 years ago
|
package goround
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
// FloatRound 截取小数位数
|
||
|
func FloatRound(f float64, n int) float64 {
|
||
|
format := "%." + strconv.Itoa(n) + "f"
|
||
|
res, _ := strconv.ParseFloat(fmt.Sprintf(format, f), 64)
|
||
|
return res
|
||
|
}
|