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

Method randrange

src/random.h:104–112  ·  view source on GitHub ↗

Generate a random integer in the range [0..range). */

Source from the content-addressed store, hash-verified

102
103 /** Generate a random integer in the range [0..range). */
104 uint64_t randrange(uint64_t range)
105 {
106 --range;
107 int bits = CountBits(range);
108 while (true) {
109 uint64_t ret = randbits(bits);
110 if (ret <= range) return ret;
111 }
112 }
113
114 /** Generate random bytes. */
115 std::vector<unsigned char> randbytes(size_t len);

Callers 9

transact_and_mineMethod · 0.80
BatchWriteMethod · 0.80
PushAddressMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
InsecureRandRangeFunction · 0.80
PrevectorJobMethod · 0.80
generate_saltFunction · 0.80

Calls 1

CountBitsFunction · 0.85

Tested by 4

BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
InsecureRandRangeFunction · 0.64