From 547b703e10fbe81ed02843dc0121fdc849d08c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 27 Apr 2020 14:10:29 +0800 Subject: [PATCH] =?UTF-8?q?utils=20=E6=96=B0=E5=A2=9E=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/typeconv.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/typeconv.go b/utils/typeconv.go index 51d75ec0..5acea05d 100644 --- a/utils/typeconv.go +++ b/utils/typeconv.go @@ -538,3 +538,7 @@ func IntSlice2Int64(intList []int) (outList []int64) { func Int2Float64(i int) (f float64) { return Str2Float64(Int64ToStr(int64(i))) } + +func Float32ToInt(f float32) (i int) { + return int(Str2Int64(Float64ToStr(math.Round(float64(f))))) +}