Random number generator (included): Difference between revisions

Added Quackery.
(Added Quackery.)
Line 658:
=={{header|Python}}==
Python uses the [[wp:Mersenne twister|Mersenne twister]] algorithm accessed via the built-in [http://docs.python.org/library/random.html random module].
 
=={{header|Quackery}}==
 
Quackery uses the 64 bit variant of Bob Jenkins' public domain "A small noncryptographic PRNG", which can be found at [https://burtleburtle.net/bob/rand/smallprng.html burtleburtle.net].
 
In case the website does not endure, the C implementation provided is:
 
<lang C>typedef unsigned long long u8;
typedef struct ranctx { u8 a; u8 b; u8 c; u8 d; } ranctx;
 
#define rot(x,k) (((x)<<(k))|((x)>>(64-(k))))
u8 ranval( ranctx *x ) {
u8 e = x->a - rot(x->b, 7);
x->a = x->b ^ rot(x->c, 13);
x->b = x->c + rot(x->d, 37);
x->c = x->d + e;
x->d = e + x->a;
return x->d;
}
 
void raninit( ranctx *x, u8 seed ) {
u8 i;
x->a = 0xf1ea5eed, x->b = x->c = x->d = seed;
for (i=0; i<20; ++i) {
(void)ranval(x);
}
}</lang>
 
=={{header|R}}==
1,462

edits