3 * This is my favorite tiny RNG, If you had a ZX81 you may recognise it :-)
9 #define MAXINT (((unsigned)-1)>>1)
11 static unsigned int sseed = 0;
15 return ( sseed = (((sseed+1L)*75L)%65537L)-1 ) & MAXINT;
27 * This generator is a combination of three linear congruential generators
28 * with periods or 2^15-405, 2^15-1041 and 2^15-1111. It has a period that
29 * is the product of these three numbers.
35 #define MAXINT (((unsigned)-1)>>1)
37 #define CRANK(a,b,c,m,s) \
39 s = b*(s-a*q) - c*q; \
45 CRANK(206, 157, 31, 32363, seed1);
46 CRANK(217, 146, 45, 31727, seed2);
47 CRANK(222, 142, 133, 31657, seed3);
49 return seed1^seed2^seed3;
56 seed1= seed%32362 + 1;
57 seed2= seed%31726 + 1;
58 seed3= seed%31656 + 1;