Restrict global and function references to memory size
This commit is contained in:
10
gen/rand.go
10
gen/rand.go
@@ -9,6 +9,16 @@ func RandBiasedUint64() uint64 {
|
||||
return (rand.Uint64() | 0x8000000000000000) >> rand.Intn(65)
|
||||
}
|
||||
|
||||
// Like RandBiasedUint64() but always returns < n
|
||||
func RandBiasedUint64n(n uint64) uint64 {
|
||||
for {
|
||||
ret := RandBiasedUint64()
|
||||
if ret < n {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate a random int64 with an even distribution of the tuple
|
||||
// {sign, bits.Len64(math.Abs())}
|
||||
func RandBiasedInt64() uint64 {
|
||||
|
||||
Reference in New Issue
Block a user