how do random numbers on computers work?

1.42K views

For example, is there a formula for a random number?

In: 47

75 Answers

Anonymous 0 Comments

There are two types of random numbers in computers.

The first, is “pseudorandom” (meaning “sort of random”) numbers which, like you suggest is done using an algorithm. They start with a number (maybe they start with the date and time the program started), and then they do a calculation to generate a number. The next time you ask for a number, they perform the same calculation to get a new number, and so on… You start with some number and from there you get a series of numbers that look random. Importantly, whenever you start with the same number, you get the same series of random-looking numbers.

The other way to do it is a bit slower, but it involves grabbing bits of data from different parts of the computer, like variations in the CPU temperature, time intervals between network packets, jitter in mouse movements, etc. things happening in the computer that are themselves kind of random, but combined can be used to generate a random number. This is slower because it depends on monitoring several bits of computer activity instead of just a quick bit of arithmetic.

You are viewing 1 out of 75 answers, click here to view all answers.