How do random number generator works? (for example in C/C++ Java)
How can I write my own random number generator? (for example in C/C++ Java)
How do random number generator works? (for example in C/C++ Java)
How can I write my own random number generator? (for example in C/C++ Java)
I found this one for Java:
http://www.javamex.com/tutorials/random_numbers/java_util_random_algorithm.shtml
by googling how random functions work java
I'm sure the answer is language-specific, but you can try altering my Google query for the language of your choice.
Maybe you can start here: http://en.wikipedia.org/wiki/Random_number_generation
One of the things to keep in mind is that there are no 'true' random number generators. They just generate numbers that look random to us mere mortals.
One of the easiest examples of this (to implement, as well) is the Linear congruential generator. Sure, the numbers look unpredictable to you and me, but they're actually evenly spaced within a finite field.
Of course, some generators, like Blum Blum Shub aren't predictable for an outsider even if he applies serious mathematical skills and computing power to the task, but at the fundamental level, random number generators aren't random; they're regular and predictable.
There is a lot of information available about how they are working ... see Konamiman's answer and use google a bit.
Why would you like to write a new random generator? You probably should not try to do so ... until you need something very special. For example in a game you could use a shuffle bag which produces 'fair' random values - have a look at this interesting question on SO.
I post this here, because I really liked the idea and implementation when I read about it the first time :)