wangchuanjin 5 years ago
parent
commit
0cddab7b90
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/qfw/util/common.go

+ 6 - 0
src/qfw/util/common.go

@@ -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
+}