You mean how does it calculate a random number?

Short answer: It doesn't. Not a truly random number anyway. Random numbers generated by software actually use what's known as a

pseudo-random number generator (PRNG), which is a complex algorithm that takes a number passed to it (known as a

seed) and uses this as a starting number from which to operate the algorithm on. There are many different algorithms used for PRNGs, one of the better known ones is the

Mersenne Twister.

Since all PRNGs are just forms of algorithms they are not truly random, and given the same seed they will yield the same number (this can actually be a very useful feature to take advantage of in certain programming situations). This also means that over a large enough period (a very very large period in modern computing) a PRNG will eventually repeat the exact same sequence of numbers.

If you're wondering why you don't have to pass a seed to $rand() when you use it it's because it's done automagically behind the scenes by mIRC.

See

here for a more complete description of pseudo-random number generation.