1
0

FastRandom rewrite (#3754)

This commit is contained in:
peterbell10
2017-06-13 20:35:30 +01:00
committed by Lukas Pioch
parent 9b0eb118b3
commit 360d8eade0
63 changed files with 467 additions and 417 deletions

View File

@@ -15,14 +15,13 @@ static void TestInts(void)
cFastRandom rnd;
int sum = 0;
const int BUCKETS = 8;
int Counts[BUCKETS];
memset(Counts, 0, sizeof(Counts));
int Counts[BUCKETS] = {0};
const int ITER = 10000;
for (int i = 0; i < ITER; i++)
{
int v = rnd.NextInt(1000);
int v = rnd.RandInt(1000);
assert_test(v >= 0);
assert_test(v < 1000);
assert_test(v <= 1000);
Counts[v % BUCKETS]++;
sum += v;
}
@@ -43,12 +42,11 @@ static void TestFloats(void)
cFastRandom rnd;
float sum = 0;
const int BUCKETS = 8;
int Counts[BUCKETS];
memset(Counts, 0, sizeof(Counts));
int Counts[BUCKETS] = {0};
const int ITER = 10000;
for (int i = 0; i < ITER; i++)
{
float v = rnd.NextFloat(1000);
float v = rnd.RandReal(1000.0f);
assert_test(v >= 0);
assert_test(v <= 1000);
Counts[static_cast<int>(v) % BUCKETS]++;
@@ -76,7 +74,7 @@ static void TestReCreation(void)
for (int i = 0; i < ITER; ++i)
{
cFastRandom rnd;
int val = rnd.NextInt(10);
int val = rnd.RandInt(9);
if (val == lastVal)
{
numSame += 1;