@@ -45,6 +45,10 @@ int[] getMakotoNishimuraTestSeed() {
45
45
return ARRAY_SEED ;
46
46
}
47
47
48
+ // the below reference values are provided by the original authors
49
+ // for the seed array {0x123, 0x234, 0x345, 0x456}
50
+ // http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.out
51
+ // {0x123, 0x234, 0x345, 0x456}
48
52
@ Test
49
53
public void testMakotoNishimura () {
50
54
ReversibleMersenneTwister mt = makeGenerator ();
@@ -305,15 +309,15 @@ public void testMakotoNishimura() {
305
309
};
306
310
307
311
for (long expectedInt : refInt ) {
308
- int r = mt .nextInt ();
309
- assertEquals (expectedInt , ( r & 0x7FFFFFFFL ) | (( r < 0 ) ? 0x80000000L : 0x0L ) );
312
+ long r = (( long ) mt .nextInt ()) & 0xFFFFFFFFL ; // poor man unsigned int
313
+ assertEquals (expectedInt , r );
310
314
}
311
315
316
+ // {@code genrand_real2} function from the original code
317
+ // {@code genrand_int32() * (1.0 / 4294967296.0)}
312
318
for (double expectedDouble : refDouble ) {
313
- int r = mt .nextInt ();
314
- assertEquals (expectedDouble ,
315
- ((r & 0x7FFFFFFFL ) | ((r < 0 ) ? 0x80000000L : 0x0L )) / 4294967296.0 ,
316
- 1.0e-8 );
319
+ long r = ((long ) mt .nextInt ()) & 0xFFFFFFFFL ; // poor man unsigned int
320
+ assertEquals (expectedDouble , r / 4294967296.0 , 1.0e-8 );
317
321
}
318
322
}
319
323
0 commit comments