mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-20 17:57:54 +00:00
upgrade:float64 formatting method
This commit is contained in:
+9
-1
@@ -1,7 +1,15 @@
|
||||
package tools
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Float64ToString(e float64) string {
|
||||
return strconv.FormatFloat(e, 'E', -1, 64)
|
||||
}
|
||||
|
||||
func Round(f float64, n int) float64 {
|
||||
pow10_n := math.Pow10(n)
|
||||
return math.Trunc((f+0.5/pow10_n)*pow10_n) / pow10_n // TODO +0.5 是为了四舍五入,如果不希望这样去掉这个
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user