Template:Random

A template that generates a pseudo-random number in several ways.

Random seed is current time - note that due to browser caching, this template may actually write the same number until the page is fetched again from the server.

Syntax
  or    or   

Examples of usage

 * Return a random decimal number in range from 0 to 1


 * Returns a random integer in range from 1 to 5 (both included)


 * Returns a random integer in range from -2 to 3 (both included)

Technical details
The calculated number isn't truly random (probably not even uniformly distributed), but should be relatively close to it for the purpose of choosing between a small number of ranges.

First we take the standard Unix time (Number of seconds since January 1 1970 00:00:00 GMT)and raise it the power of number of seconds passed since the start of the minute divided by 122 (in other words, to the number in range of 1/122 - 0.5). We get a decimal number made of 15 characters, with last 9 guaranteed to be after the decimal point until around the year 2285.

Then we take the last 8 characters from that number. We calculate the fraction the number made of those 8 characters makes from the largest 8-digit number (99999999). That is the number the template writes if no arguments are given.

In case the arguments are given, scaling and translation of basic 0-1 range is performed to give the right results.