Fixed unit float and unit double generators.
This commit is contained in:
parent
7d8de2d4ba
commit
8632b5f433
3 changed files with 12 additions and 5 deletions
|
@ -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());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue