Subject: Random number generator
From: [email-masked] (Patrick J. Fay)

8 Jan 1998 02:18:57 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: [email-masked]
Cc: [email-masked]

Try:
PREINSTALLED /pfay/memory 262 > cat tst.c
#include <stdlib.h>
#include <math.h>
int rand100()
{
   double rmax=100.0/RAND_MAX;
   return((int)(rmax*(rand())));
}
int main()
{
   int i;

   for(i=0;i<10;i++)
   {
           printf("rand100=%d\n",rand100());
   }
   return 0;
}
PREINSTALLED /pfay/memory 263 > !gc
gcc tst.c -o tstc
PREINSTALLED /pfay/memory 264 > !./t
../tstc
rand100=51
rand100=17
rand100=30
rand100=53
rand100=94
rand100=17
rand100=70
rand100=22
rand100=49
rand100=12 

Patrick Fay, Ph.D., Intel Corp.            email:   [email-masked]
Los Alamos National Lab                    wk:         (505) 665-9141
CTI M.S. B296                              fax:        (505) 667-5921
Los Alamos NM 87545    ASCI-RED http://www.acl.lanl.gov/~pfay/teraflop

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".