|
From: Per W. <pw...@ia...> - 2003-03-20 11:57:42
|
The problem with the normal rand() is that the low bits of it are not very rando, so rand()%11 have a tendancy to generate a very ugly pattern. /Per W On Thu, 20 Mar 2003, Zodiaq wrote: > Hello Daniel and all Dev-C++ users, > > Thursday, March 20, 2003, 12:04:44 PM, Daniel wrote as follows: > > DG> ??? Are you sure? I thought the seed was used to make numbers 'more random'? > DG> Can you explain seeding a little bit more? > > random numbers generated by rand() are generated by this algorithm: > -take some number - here where srand() is used > -add to "some number" A VERY BIG INT (constant value, I don't know > exactly what it is) which generates new number which is bigger than > biggest possible int value - when this happens "some number" new value > is exactly what is over max_int > > Each time you use rand() second part is repeated and "some number" > value returned... for this algorithm most important is value of "A > VERY BIG INT"... there are also some more advanced algorithms in net, > but this one is fast and for almost every case just enough - it > generated "pseudo random" numbers... > > -- > regards, Zodiaq > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Tablet PC. > Does your code think in ink? You could win a Tablet PC. > Get a free Tablet PC hat just for playing. What are you waiting for? > http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |