I just browsed through chapter 10 of Leo Brodie's Starting Forth (available on the web) and found this:
Handy Hint: A Random Number Generator This simple random number generator can be useful for games, although for more sophisticated applications such as simulations, better versions are available. ( Random number generation -- High level ) VARIABLE rnd HERE rnd ! : RANDOM rnd @ 31421 * 6927 + DUP rnd ! ; : CHOOSE ( u1 -- u2 ) RANDOM UM* NIP ; ( where CHOOSE returns a random integer within the range 0 = or < u2 < u1. ) Here's how to use it: To choose a random number between zero and ten (but exclusive of ten) simply enter 10 CHOOSE and CHOOSE will leave the random number on the stack. Karl On May 9, 2012, at 12:13 PM, Jan Kromhout wrote: > Hello, > > I need a random number generator in AMForth. > (It may be a generator thats generate 0..1023 as an integer) > > Has someone make this one for AMForth? > > Regards, > > Jan Kromhout > Hellevoetsluis-NL > > ---------------------------------------------------------------------- > -------- > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. > Discussions > will include endpoint security, mobile security and the latest in > malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Amforth-devel mailing list for http://amforth.sf.net/ > Amforth-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/amforth-devel ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel