Edge Rewrite
// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a23834f7ef38f43c

Jump to content

Template:Random number/testcases

From Wikipedia, the free encyclopedia

Testing sandbox version compared to main version

[edit]
Clic purge to get new ouputs.
CodeResult with sandbox templateResult with main templateNote
{{Random number}}6666default parameters (results range is 0..99)
{{Random number|100|210|67}} 66 (ok) 66 (ok) should be same as above (the default seed depends on current day of year, the default prime is 67)
{{Random number|10000}}63666366new parameters (results range in 0..9999)
{{Random number|10000|210|67}} 6366 (ok) 6366 (ok) Should be same as above
{{Random number|10000|210|61}} 6254 6254 (use another prime) this and others should all be different
{{Random number|10000|6}}26982698(varying the seed) note that the sequence is linear but the distance only depends on the value of the default prime (67)
{{Random number|10000|5}}26312631
{{Random number|10000|4}}25642564
{{Random number|10000|3}}24972497
{{Random number|10000|2}}24302430
{{Random number|10000|1}}23632363
{{Random number|10000|0}}22962296
{{Random number|10000|6|2}}96339633(varying the seed) with a small prime (2) should still get distinct values in the linear sequence
{{Random number|10000|5|2}}96319631
{{Random number|10000|4|2}}96299629
{{Random number|10000|3|2}}96279627
{{Random number|10000|2|2}}96259625
{{Random number|10000|1|2}}96239623(varying now the prime number) should get distinct non-linear sequences
{{Random number|10000|1|3}}44334433
{{Random number|10000|1|5}}40554055
{{Random number|10000|1|7}}36813681
{{Random number|10000|1|11}}29312931
{{Random number|10000|1|13}}25472547
{{Random number|10000|1|17}}18011801
{{Random number|10000|1|19}}14141414
{{Random number|10000|1|23}}660660
{{Random number|10000|1|29}}95259525
{{Random number|10000|1|31}}91709170
{{Random number|10000|1|37}}80338033
{{Random number|10000|1|41}}72777277
{{Random number|10000|1|43}}68796879
{{Random number|10000|1|47}}61326132
{{Random number|10000|1|51}}54095409
{{Random number|10000|1|53}}50045004
{{Random number|10000|1|59}}38953895
{{Random number|10000|1|61}}35053505
{{Random number|10000|1|67}}23632363
{{Random number|10000|1|71}}16071607
{{Random number|10000|1|73}}12561256
{{Random number|10000|1|79}}130130

Sandbox notes

[edit]

This version uses fmod builtin operator (no longer need of Template:Mod) and the largest Mersenne prime (231−1) that fits in 32 bits.

This Mersenne prime is chosen to offer equal distribution when reducing the number of digits (better than bitmasking by an exact power of 2).

The next Mersenne prime (261−1) is too large to fit in 64-bit integers for computing products by reasonable primes (we could only use 2, 3, 5 or 7), or even just in the 52 bits of precision of a double float (used by #expr).