\ -*- mode: forth -*- \ $Id: random.bigforth,v 1.1 2001/06/20 23:23:29 doug Exp $ \ http://www.bagley.org/~doug/shootout/ \ based on code from Marcel Hendrix \needs float import float float also \ read NUM from last command line argument 0. argc @ 1- arg >number 2drop drop constant NUM 139968 CONSTANT IM 3877 CONSTANT IA 29573 CONSTANT IC IM S>D D>F 1e FSWAP F/ FCONSTANT FIM 42 VALUE seed : format-float ff$ type ; : IM_mod S" DUP $001DF757 UM* NIP $FFFFFFC0 AND 2187 * - " EVALUATE ; IMMEDIATE : gen_random S" seed IA * IC + IM_mod DUP TO seed 0 D>F " EVALUATE S" FIM F* F* " EVALUATE ; IMMEDIATE : MAIN NUM 10 SET-PRECISION 0e BEGIN ?DUP WHILE 1- FDROP 100e0 gen_random REPEAT format-float cr ; MAIN bye