mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve package grand
This commit is contained in:
@ -6,7 +6,7 @@ require (
|
||||
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.0.0-rc2
|
||||
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.0.0-rc2
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.0.0-rc2
|
||||
github.com/gogf/gf/v2 v2.0.0-rc
|
||||
github.com/gogf/gf/v2 v2.0.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
)
|
||||
|
||||
|
||||
@ -60,16 +60,12 @@ func N(min, max int) int {
|
||||
return min
|
||||
}
|
||||
if min >= 0 {
|
||||
// Because Intn dose not support negative number,
|
||||
// so we should first shift the value to left,
|
||||
// then call Intn to produce the random number,
|
||||
// and finally shift the result back to right.
|
||||
return Intn(max-(min-0)+1) + (min - 0)
|
||||
return Intn(max-min+1) + min
|
||||
}
|
||||
if min < 0 {
|
||||
// Because Intn dose not support negative number,
|
||||
// As `Intn` dose not support negative number,
|
||||
// so we should first shift the value to right,
|
||||
// then call Intn to produce the random number,
|
||||
// then call `Intn` to produce the random number,
|
||||
// and finally shift the result back to left.
|
||||
return Intn(max+(0-min)+1) - (0 - min)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user