random number between -1 and 1

hi please help me how to generate random number range between -1 and 1.
following code works but just in range between 0 and 1
1
2
3
4
    int min = -1;
    int max = 1;
	float r = (float)rand() / (float)RAND_MAX;
	return min + r * (max - min);

thanks
That code works for me.
Topic archived. No new replies allowed.