// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
// Uniform32 algorithm
//
// L'Ecuyer CACM Jun 1988.
//
// cycle = approx. 2.31E18

public class Uniform32 extends Combined {
    private static class Uniform32Combiner implements Combiner {
        public int combine(int[] num) {
            long tmp = num[0] - num[1];
            tmp = (tmp + 2147483562) % 2147483562;
            return (int)tmp;
        }
        public int getMaxInt() {
            return 2147483562;
        }
    }
    public Uniform32(int seed1, int seed2) {
        super(new RNG[] { new MLCG(40014, 2147483563, seed1), new MLCG(40692, 2147483399, seed2) },
              new Uniform32Combiner());
    }
}

