Me? I would most likely do what I did when I needed random numbers that were inside a sphere. Generate random numbers between -1 and 1 (inclusive), and if it s >= 1.0 or <= -1.0 then just loop and try again.... so
Code:do { x = (double)rand()/RAND_MAX*2.0-1.0; while(x <= -1.0 || x >= 1.0);
Guys, I am sorry to be late to deliver THANKS to everyone. Appreciated so much that I have learned from your code. Thanks again.