Hello there,
To get to the point, I have this function:
Code:
double fractNum(int limit)
{
int x = rand() % (limit + 1);
double y = rand() % ACCURACY;
y/= ACCURACY;
y+=x;
return y;
}
where ACCURACY equals 1000
srand is seeded like this:
Code:
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
the function is called like this:
Code:
object[x].realX = fractNum(HIGHT);
object[x].realY = fractNum(LENGTH);
where HIGHT and LENGTH equal 10, x is being incremented by a loop, and object is a struct, but that doesn't really matter.
What this should do is assign a real value to realX/Y, between 0.000 and 9.999. The problem is, instead I get gross values like -282433580....goes on for around 30 digits plus a couple after the decimal point. I have no idea what's going on...the problem seems to be in the random generator, as far as I could tell....anyone see the problem I've missed? :-)
Thanks,
G4B3