Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!ism780c!tim From: tim@ism780c.UUCP (Tim Smith) Newsgroups: net.sources Subject: Re: mz.c Message-ID: <4319@ism780c.UUCP> Date: Fri, 7-Nov-86 19:32:57 EST Article-I.D.: ism780c.4319 Posted: Fri Nov 7 19:32:57 1986 Date-Received: Sun, 9-Nov-86 03:16:28 EST References: <4247@ism780c.UUCP> <823@zen.BERKELEY.EDU> <1125@cit-vax.Caltech.Edu> Reply-To: tim@ism780c.UUCP (Tim Smith) Followup-To: net.sources.d Organization: Interactive Systems Corp., Santa Monica, CA Lines: 19 Note: followups are being redirected to net.sources.d In article <1125@cit-vax.Caltech.Edu> trent@cit-vax.UUCP (Ray Trent) writes: > >I suppose this works...but isn't: > > #define oneof(n) (rand() % (n) + 1) > >more intuitive and efficient? Yes, but it also doesn't work! If n is not a divisor of 32768, the distribution will be off. For example, if n is 24000, then numbers from 1 to 8000 will be given twice as often as numbers from 9000 to 24000. -- emordnilapanalpanama Tim Smith USENET: sdcrdcf!ism780c!tim Compuserve: 72257,3706 Delphi or GEnie: mnementh