mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
update grand.MeetProb, change param type from float64 to float32
This commit is contained in:
@ -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 别名
|
||||
|
||||
@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user