Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!oberon!oxy!bagpiper From: bagpiper@oxy.edu (Michael Paul Hunter) Newsgroups: comp.lang.c Subject: Re: How do I get random #s? Message-ID: <16034@tiger.oxy.edu> Date: 5 Feb 89 19:54:50 GMT References: <19415@dhw68k.cts.com> <9570@smoke.BRL.MIL> Organization: Occidental College, Los Angeles, CA 90041 Lines: 19 In article <9570@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: >In article <19415@dhw68k.cts.com> tsource@dhw68k.cts.com (Aryeh Friedman) writes: >> I am new to C and I want to know how to get random numbers returned. > >Unfortunately the specific details of pseudo-random number generators >in the system C libraries vary from system to system. Usually there >is one called rand(), sometimes random(). UNIX System V has a family >*rand48(). > >ANSI C requires rand() to be provided, but probably your best bet for >the time being is to provide your own generator. For example: > How about a quick hack at a random number generator that is kindof-fairly uniorm in [0, 1]. My quick answer is to scale rand...but that doesn't seem to be the best quick hack answer to me. Mike