mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
Use std::numeric_limits<> for typesafe INT_MAX/etc
This commit is contained in:
parent
bd846c0e56
commit
26ce92b352
13 changed files with 26 additions and 34 deletions
|
|
@ -133,7 +133,7 @@ uint64 GetRand(uint64 nMax)
|
|||
|
||||
// The range of the random source must be a multiple of the modulus
|
||||
// to give every possible output value an equal possibility
|
||||
uint64 nRange = (UINT64_MAX / nMax) * nMax;
|
||||
uint64 nRange = (std::numeric_limits<uint64>::max() / nMax) * nMax;
|
||||
uint64 nRand = 0;
|
||||
do
|
||||
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue