11 lines
318 B
Go
11 lines
318 B
Go
package gen
|
|
|
|
import "math/rand"
|
|
|
|
// Generate a random uint64 with an even distribution of bits.Len64()
|
|
func RandBiasedUint64() uint64 {
|
|
// The shift-right by up to 64 (shifting it to 0) makes up for randomness
|
|
// lost by setting the high bit.
|
|
return (rand.Uint64() | 0x8000000000000000) >> rand.Int31n(65)
|
|
}
|