problem with rand()
Hi Everybody
I am using rand function in my solver and somehow I need random numbers between 0 and 6 but the problem is that when I simply use rand() function, I get unexpected huge numbers and these numbers are constant run by run. I have read somewhere in forum that rand(an integer) should work.but in my case I have error. can anyone help me with this? thanks in advance |
rand() returns an int, so you need to normalize by RAND_MAX and convert to float/double if necessary. And if you don't use srand() to seed the PRNG, you will always get the same sequence.
http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx |
thanks Micheal
now it is working fine |
All times are GMT -4. The time now is 08:12. |