MCPcopy Create free account
hub / github.com/beefytech/Beef / NextRandom

Method NextRandom

BeefRT/gperftools/src/sampler.h:155–162  ·  view source on GitHub ↗

Returns the next prng value. pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 This is the lrand64 generator.

Source from the content-addressed store, hash-verified

153// pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48
154// This is the lrand64 generator.
155inline uint64_t Sampler::NextRandom(uint64_t rnd) {
156 const uint64_t prng_mult = 0x5DEECE66DLL;
157 const uint64_t prng_add = 0xB;
158 const uint64_t prng_mod_power = 48;
159 const uint64_t prng_mod_mask =
160 ~((~static_cast<uint64_t>(0)) << prng_mod_power);
161 return (prng_mult * rnd + prng_add) & prng_mod_mask;
162}
163
164// Adapted from //util/math/fastmath.[h|cc] by Noam Shazeer
165// This mimics the VeryFastLog2 code in those files

Callers 3

TestNextRandomFunction · 0.45
TestLRand64SpreadFunction · 0.45
TESTFunction · 0.45

Calls

no outgoing calls

Tested by 3

TestNextRandomFunction · 0.36
TestLRand64SpreadFunction · 0.36
TESTFunction · 0.36