43 const unsigned long long int chunk_width = 1ULL << 31;
46 if ((width <= chunk_width) || (width > (1ULL << 32)))
50 const unsigned long long int source_width = 1ULL << 62;
51 const unsigned long long int limit =
52 source_width - (source_width % width);
53 unsigned long long int sample;
56 (
static_cast<unsigned long long int>(
57 random(
static_cast<unsigned int>(chunk_width))) << 31) |
58 random(
static_cast<unsigned int>(chunk_width));
59 }
while (sample >= limit);
60 return sample % width;