diff --git a/ChangeLog b/ChangeLog index 9ef9d4b2cb..02acc2ebba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jul 30 21:48:56 2009 Yusuke Endoh + + * random.c (init_genrand): ensure invariant of mt->next and mt->left. + mt->next should always equal mt->state + N + 1 - mt->left. + In fact, 'r = Random.new(0); r == r.dup' has returned false. + Thu Jul 30 21:43:41 2009 Yusuke Endoh * random.c (random_bytes): use NUM2LONG instead of FIX2LONG because diff --git a/random.c b/random.c index bfdfaf6f3c..7aefb4d4fb 100644 --- a/random.c +++ b/random.c @@ -98,7 +98,7 @@ init_genrand(struct MT *mt, unsigned int s) mt->state[j] &= 0xffffffff; /* for >32 bit machines */ } mt->left = 1; - mt->next = mt->state + N - 1; + mt->next = mt->state + N; } /* initialize by an array with array-length */