[Core/Utilities] Implement random generator for float values.

*for mt and sfmt
 *some codestyle
This commit is contained in:
Chaplain committed 2012-01-02 12:38:55 +03:00
1 parent ced346076b
commit 29c2dfb1da
2 files changed
+21 -7

No files matched your search

+18 -7
View File
@@ -30,17 +30,22 @@
typedef ACE_TSS<SFMTRand> SFMTRandTSS;
static SFMTRandTSS sfmtRand;
int32 irand (int32 min, int32 max)
int32 irand(int32 min, int32 max)
{
return int32(sfmtRand->IRandom(min, max));
}
uint32 urand (uint32 min, uint32 max)
uint32 urand(uint32 min, uint32 max)
{
return sfmtRand->URandom(min, max);
}
int32 rand32 ()
float frand(float min, float max)
{
return float(sfmtRand->Random() * (max - min) + min);
}
int32 rand32()
{
return int32(sfmtRand->BRandom());
}
@@ -50,27 +55,33 @@ double rand_norm(void)
return sfmtRand->Random();
}
double rand_chance (void)
double rand_chance(void)
{
return sfmtRand->Random() * 100.0;
}
#else
typedef ACE_TSS<MTRand> MTRandTSS;
static MTRandTSS mtRand;
int32 irand(int32 min, int32 max)
{
return int32(mtRand->randInt (max - min)) + min;
return int32(mtRand->randInt(max - min)) + min;
}
uint32 urand(uint32 min, uint32 max)
{
return mtRand->randInt (max - min) + min;
return mtRand->randInt(max - min) + min;
}
float frand(float min, float max)
{
return float(mtRand->randExc(max - min) + min);
}
int32 rand32()
{
return mtRand->randInt ();
return mtRand->randInt();
}
double rand_norm(void)