From f81b89070e42fa262fab901548ca1794b208985b Mon Sep 17 00:00:00 2001 From: zhangxin Date: Fri, 12 Mar 2021 17:25:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Round=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/utils.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/utils.go b/utils/utils.go index d449559..e3bed07 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/lianggx6/goutf16" "io" + "math" "math/rand" "net/http" "os" @@ -386,4 +387,10 @@ func FileExist(file string) bool { } return true +} + +func Round(num float64) int { + num += 0.5 + num = math.Floor(num) + return int(num) } \ No newline at end of file