41 if (
this == &getSystemRandom())
80 seed = (int64) (((((
uint64) seed) * 0x5deece66dLL) + 11) & 0xffffffffffffLL);
82 return (
int) (seed >> 16);
87 jassert (maxValue > 0);
88 return (
int) ((((
unsigned int) nextInt()) * (
uint64) maxValue) >> 32);
93 return range.getStart() + nextInt (range.getLength());
103 return (
nextInt() & 0x40000000) != 0;
108 return static_cast<uint32> (
nextInt()) / (std::numeric_limits<uint32>::max() + 1.0f);
113 return static_cast<uint32> (
nextInt()) / (std::numeric_limits<uint32>::max() + 1.0);
131 int* d =
static_cast<int*
> (buffer);
173 :
UnitTest (
"Random", UnitTestCategories::maths)
176 void runTest()
override
178 beginTest (
"Random");
180 Random r = getRandom();
182 for (
int i = 2000; --i >= 0;)
184 expect (r.nextDouble() >= 0.0 && r.nextDouble() < 1.0);
185 expect (r.nextFloat() >= 0.0f && r.nextFloat() < 1.0f);
186 expect (r.nextInt (5) >= 0 && r.nextInt (5) < 5);
187 expect (r.nextInt (1) == 0);
189 int n = r.nextInt (50) + 1;
190 expect (r.nextInt (n) >= 0 && r.nextInt (n) < n);
192 n = r.nextInt (0x7ffffffe) + 1;
193 expect (r.nextInt (n) >= 0 && r.nextInt (n) < n);
198static RandomTests randomTests;
float nextFloat() noexcept
void fillBitsRandomly(void *bufferToFill, size_t sizeInBytes)
void combineSeed(int64 seedValue) noexcept
int64 nextInt64() noexcept
void setSeed(int64 newSeed) noexcept
double nextDouble() noexcept
BigInteger nextLargeNumber(const BigInteger &maximumValue)
static Random & getSystemRandom() noexcept
static int64 getHighResolutionTicks() noexcept
static int64 currentTimeMillis() noexcept
static int64 getHighResolutionTicksPerSecond() noexcept
static uint32 getMillisecondCounter() noexcept