MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / randbits

Method randbits

src/random.h:89–101  ·  view source on GitHub ↗

Generate a random (bits)-bit integer. */

Source from the content-addressed store, hash-verified

87
88 /** Generate a random (bits)-bit integer. */
89 uint64_t randbits(int bits) {
90 if (bits == 0) {
91 return 0;
92 } else if (bits > 32) {
93 return rand64() >> (64 - bits);
94 } else {
95 if (bitbuf_size < bits) FillBitBuffer();
96 uint64_t ret = bitbuf & (~(uint64_t)0 >> (64 - bits));
97 bitbuf >>= bits;
98 bitbuf_size -= bits;
99 return ret;
100 }
101 }
102
103 /** Generate a random integer in the range [0..range). */
104 uint64_t randrange(uint64_t range)

Callers 4

Select_Method · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
InsecureRandBitsFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls

no outgoing calls

Tested by 3

BOOST_AUTO_TEST_CASEFunction · 0.64
InsecureRandBitsFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64