I am working on a small maths library and can't seem to get a reliable random
seed number generator working for floats that take a seed as an input.
The problem seems to be down to srand()
. The reason for this conclusion is because when I feed a series of low seeds into the function I get results from 0.004f - 0.005f
and this is when the min/max values of the function are set to 0.0f
and 1.0f
respectively.
float SFRandomNumber(int& seed, float min, float max, bool change_seed) {
srand(seed);
if (change_seed) SeedToSeed(seed);
return (max - min) * ((((float)rand()) / (float)RAND_MAX)) + min;
}
Does anyone know how I can improve my current implementation?
Aucun commentaire:
Enregistrer un commentaire