From 21e158606061246c7fcabb07b18bc5bc2f001054 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 7 Oct 2020 01:21:08 -0700 Subject: random: bugfix: incorrect WELL512a. * rand.c (rand32_bug): New static function formed by renaming the original buggy rand32. (rand32_good): Copy of rand32 with two bugfixes. The term involving variable r2 must be only left shifted by 28 bits, and not xor-ed with the original value. The order of operations is wrong in the term that contains the & operation. (rand32): New static function pointer variable, serving as the rand32 function. Points to rand32_good by default. (rand_compat_fixup): Test for 243 or lower compatibility, under which rand32 is made point to rand32_bug. This is done before the call to make_random_state for replacing *random-state*, which has to use the old function. * txr.1: compat note added. * tests/013/maze.expected: Updated. --- txr.1 | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 2088419c..067f9b80 100644 --- a/txr.1 +++ b/txr.1 @@ -75522,6 +75522,14 @@ of these version values, the described behaviors are provided if is given an argument which is equal or lower. For instance .code "-C 103" selects the behaviors described below for version 105, but not those for 102. +.IP 243 +Two mistakes in the pseudo-random-number generator (PRNG) were discovered, +affecting \*(TX 243 and older. Using this compatibility value, or lower, will +restore the buggy behavior, allowing pseudo-random number sequences produced +by those older versions can be reproduced. The PRNG is intended to be an +implementation of the WELL-512 PRNG described by Panneton and L'Ecuyer. +The coding mistakes, however, resulted in the PRNG being an implementation of +something other than WELL-512. .IP 242 In \*(TX 242 and older, the instantiation of an object whose type inherits from the same supertype more than once resulted in duplicate execution -- cgit v1.2.3