Random numbers.

Hello,

If a series of Points (i.e. x and y coordinates) is generated randomly using this function:
1
2
3
4
5
6
7
8
9
10
11
12
13
void initPoints(){
	x = new double[nbPoints];
	y = new double[nbPoints];
	srand(2007);
	double eps = 0.000001f;

	for (int i=0; i!=nbPoints; i++){
		x[i] = (((double)rand())/RAND_MAX)*maxCoord;
		if (x[i] == maxCoord) x[i] -= eps;
		y[i] = (((double)rand())/RAND_MAX)*maxCoord;
		if (y[i] == maxCoord) y[i] -= eps;
	}
}


Does it ensure the same outcomes regardless of compiler version/settings/OS/angle between Jupiter and Uranus?
closed account (1vRz3TCk)
Not necessarily.
Which factors could influence it? Better yet: given that it's always run on a Windows system in MCV++2010 (but possibly a different version), can I be certain it'll be the same?
closed account (1vRz3TCk)
Which factors could influence it?

The implementation of rand(), if you can be certain that this is always the same and will never change, then it probably would have the same outcome.
Topic archived. No new replies allowed.