Re: Random Numbers
Posted in 1995
Dave Snyder — — source: Informix-list mailing list archive (1991-1998)
Quoting Jack Parker... } } > } > } > Anybody know of a random number generator for I4gl? } > } > } } try this. } } # 4gl code } CALL c_rand() RETURNING rnd # RANDOM BETWEEN 1 AND 32767 } } } /* c code */ } #include <stdlib.h> } } c_rand() } { } retint(rand()); } return(1); } } } Unfortunately you'll get the SAME random numbers everytime you run your program! I'd recommend using srand48(time(0)); first to set an entry point for the random number generator and then I'd use lrand48(); to actually generate the random numbers. DAS -- Dave Snyder @ Bell Atlantic - Philadelphia, PA EMAIL: (w) ddx85qr@bell-atl.com (h) dave@das13.snide.com WEB: http://www.ece.vill.edu/~dave/ (Now NETSCAPE enhanced!)