The Lewis–Goodman–Miller algorithm for generating random numbers is given by the integer relation zn+1 = 16807zn mod (231 −1). The portability problem with this method is that the rules for fixed point overflow vary greatly. For a computer using two’s complement that allows an integer overflow to go unflagged, the following code was proposed:
Z = 16807 * Z
IF ( Z .LT. 0 ) Z = ( Z + 2147483647)+1
Check to see if your computer behaves this way by checking this algorithm, beginning with z1 = 1, and see if z10001 = 1043618065 (Park and Miller 1988).
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here