@@ -700,3 +700,9 @@ func SimpleCrontab(flag bool, c string, f func()) {
}
+
+//v保留n为小数,n后的四舍五入
+func RetainDecimal(v float64, n int) float64 {
+ n10 := math.Pow10(n)
+ return math.Trunc((v+0.5/n10)*n10) / n10
+}