( Title: Random Number Generator File: ren.fs Version: 0.9.0 Original Author: W. J. Cody, 1987 Ported by: David N. Williams License: ACM noncommercial use Starting date: January 10, 2003 Last revision: January 10, 2003 This is a port of W. J. Cody's REN subprogram in the celefunt package, from Fortran 77 to ANS Forth. As ACM Algorithm 714 [TOMS], the celefunt package is presumed to be under the ACM license for noncommercial use: http://www.acm.org/pubs/copyright_policy/softwareCRnotice.html There is an ANS Forth environmental dependence on lower case. Quote from the original celefunt package: Random number generator -- based on Algorithm 266 by Pike and Hill [modified by Hansson], Communications of the ACM, Vol. 8, No. 10, October 1965. This subprogram is intended for use on computers with fixed point wordlength of at least 29 bits. It is best if the floating-point significand has at most 29 bits. Latest revision - March 19, 1987 Author - W. J. Cody Argonne National Laboratory ) decimal s" FLOATING-EXT" environment? [IF] ( flag) drop s" FLOATING-STACK" environment? [IF] ( maxdepth) drop 100001 value iy \ seed the random number : ren ( f: -- r ) iy 125 * ( IY=IY*125) dup 2796203 / 2796203 * - ( IY=IY-[IY/2796203]*2796203) dup to iy 0 d>f ( f: FY=CONV[IY]) 2796203E f/ 1E 1E-6 f+ 1E-12 f+ f* ( f: FY/C1*[1+C2+C3]) ; [ELSE] .( ***Separate floating point stack not available.) [THEN] [ELSE] .( ***Floating point not available.) [THEN]