Hi,

I want to know what is the logic used for generating a random number. Can anyone tell me the algorithm for random number generation without using standard library functions?

Thanks

Recommended Answers

All 3 Replies

Hi,

I want to know what is the logic used for generating a random number. Can anyone tell me the algorithm for random number generation without using standard library functions?

Thanks

This forum has a nice tutorial on random numbers...here's the link

http://www.daniweb.com/tutorials/tutorial1769.html

>I want to know what is the logic used for generating a random number.
There's logic to generating random numbers? :p

>Can anyone tell me the algorithm for random number generation without using standard library functions?
There are a lot of algorithms for random number generation that vary from simplistic and crappy to opaque and excellent. You can have statistically random generators such as linear congruential generators (rand is almost always an LCG) or the vanilla mersenne twister, or cryptographically secure random generators like Blum Blum Shub. What you need it for is very important, but most likely you're just looking for a decent LCG. Rashakil Fol posted my recommendation for a good introduction. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.