Horde3D
http://horde3d.org/forums/

rand() doesn't really produce random numbers [SOLVED]
http://horde3d.org/forums/viewtopic.php?f=5&t=695
Page 1 of 1

Author:  Siavash [ 05.04.2009, 16:44 ]
Post subject:  rand() doesn't really produce random numbers [SOLVED]

Im always getting [exactly] same sort of numbers using rand() [math.h]. Any body knows how to generate random numbers?

Author:  swiftcoder [ 05.04.2009, 16:47 ]
Post subject:  Re: rand() doesn't really produce random numbers

Siavash wrote:
Im always getting [exactly] same sort of numbers using rand() [math.h]. Any body knows how to generate random numbers?
Use srand() to set a seed. By default, the same seed is used every time, so the same sequence of random numbers is generated. A good choice for the random seed is the current time (i.e. gettimeofday() on linux/mac).

Author:  Siavash [ 05.04.2009, 19:48 ]
Post subject:  Re: rand() doesn't really produce random numbers

Thanks a lot for help :wink:

Author:  DarkAngel [ 09.04.2009, 05:19 ]
Post subject:  Re: rand() doesn't really produce random numbers [SOLVED]

yeah, the line of code that I remember learning was: srand( time(NULL) );

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/