Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!att!pacbell.com!pacbell!well!farren From: farren@well.sf.ca.us (Mike Farren) Newsgroups: comp.sys.amiga Subject: Re: Lattice Random #s Message-ID: <22105@well.sf.ca.us> Date: 11 Dec 90 05:21:21 GMT References: <6200@crash.cts.com> Lines: 29 acota@pro-realm.cts.com (Arnold Cota) writes: >How can I get random numbers in Lattice? Well, you can use drand(), but I prefer the following (which I've hand-coded in assembler long since, for max speed, but this is the C version): /* Get a random number from 0 - , maxnum < 65536 */ unsigned long randval; void genrand() { randval *= 69069; randval += 69069; } unsigned short rand(maxnum) unsigned short maxnum; { genrand(); return ((unsigned short)(randval & 0x0ffff00) >> 8) % maxnum); } Be sure and set "randval" to some random value before calling genrand(). I use the internal clock. -- Mike Farren farren@well.sf.ca.us