mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add Random::nextBlob
This commit is contained in:
@@ -98,6 +98,23 @@ double Random::nextDouble() noexcept
|
||||
return static_cast <uint32> (nextInt()) / (double) 0xffffffff;
|
||||
}
|
||||
|
||||
void Random::nextBlob (void* buffer, size_t bytes)
|
||||
{
|
||||
int const remainder = bytes % sizeof (int64);
|
||||
|
||||
{
|
||||
int64* dest = static_cast <int64*> (buffer);
|
||||
for (int i = bytes / sizeof (int64); i > 0; --i)
|
||||
*dest++ = nextInt64 ();
|
||||
buffer = dest;
|
||||
}
|
||||
|
||||
{
|
||||
int64 const val = nextInt64 ();
|
||||
memcpy (buffer, &val, remainder);
|
||||
}
|
||||
}
|
||||
|
||||
BigInteger Random::nextLargeNumber (const BigInteger& maximumValue)
|
||||
{
|
||||
BigInteger n;
|
||||
|
||||
Reference in New Issue
Block a user