update grand.MeetProb, change param type from float64 to float32

This commit is contained in:
John
2019-01-17 14:20:18 +08:00
parent bf25a3a601
commit 485dafb616
2 changed files with 5 additions and 11 deletions

View File

@ -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 别名

View File

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