Commit 8632b5f4 authored by Markus Kauppila's avatar Markus Kauppila

Fixed unit float and unit double generators.

parent 7d8de2d4
......@@ -562,13 +562,13 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
float
RandomUnitFloat()
{
return (float) utl_randomInt(&rndContext) / UINT_MAX;
return (float) RandomUint32() / UINT_MAX;
}
double
RandomUnitDouble()
{
return (double) RandomUint64() / LLONG_MAX;
return (RandomUint64() >> 11) * (1.0/9007199254740992.0);
}
float
......@@ -599,7 +599,7 @@ RandomAsciiStringWithMaximumLength(int maxSize)
return NULL;
}
int size = (abs(RandomSint32()) % (maxSize + 1)) + 1;
int size = (RandomUint32() % (maxSize + 1)) + 1;
char *string = SDL_malloc(size * sizeof(char));
int counter = 0;
......
......@@ -111,17 +111,21 @@ Sint64 RandomSint64();
float RandomUnitFloat();
/*!
* Returns random double in range [0.0 - 1.0] (inclusive)
* Returns random double in range [0.0 - 1.0[ (note: zero included, 1 is not!)
*/
double RandomUnitDouble();
/*!
* Returns random float
* Returns random float.
*
* Note: NOT implemented.
*/
float RandomFloat();
/*!
* Returns random double
*
* Note: NOT implemented.
*/
double RandomDouble();
......
......@@ -103,6 +103,9 @@ test_dummy1(void *arg)
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
for(; 1 ; )
printf("%f\n", RandomUnitFloat());
for(; 0 ; )
printf("%d\n", RandomSint16());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment