From 485dafb6166bbd6acc2194cbd17b9896a204be91 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 17 Jan 2019 14:20:18 +0800 Subject: [PATCH] update grand.MeetProb, change param type from float64 to float32 --- g/util/grand/grand.go | 6 +++--- geg/other/test2.go | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/g/util/grand/grand.go b/g/util/grand/grand.go index ed492f6ea..d74cbc653 100644 --- a/g/util/grand/grand.go +++ b/g/util/grand/grand.go @@ -19,9 +19,9 @@ func Meet(num, total int) bool { return Rand(0, total) <= num } -// 随机计算是否满足给定的概率(float64) -func MeetProb(prob float64) bool { - return Rand(0, 1e17) <= int(prob*1e17) +// 随机计算是否满足给定的概率(float32) +func MeetProb(prob float32) bool { + return Rand(0, 1e7) <= int(prob*1e7) } // Rand 别名 diff --git a/geg/other/test2.go b/geg/other/test2.go index 65b39b5ea..9bc299382 100644 --- a/geg/other/test2.go +++ b/geg/other/test2.go @@ -1,15 +1,9 @@ package main import ( - "gitee.com/johng/gf/g/os/gcron" - "gitee.com/johng/gf/g/os/glog" - "time" + "fmt" ) func main() { - gcron.AddSingleton("* * * * * *", func() { - glog.Println("doing") - time.Sleep(2*time.Second) - }) - select { } + fmt.Println(float32(10)/3) } \ No newline at end of file