* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)rand_.c 5.4 5/13/90
* Routines to return random values
* double precision d, drand
* If arg is 1, generator is restarted. If arg is 0, next value
* is returned. Any other arg is a new seed for the generator.
* Integer values will range from 0 thru 2147483647.
* Real values will range from 0.0 thru 1.0
#if defined(vax) || defined(tahoe) || defined(hp300)
#define RANDMAX 2147483647
if (*iarg
) srand((int)*iarg
);
return(( ((long)rand()) << 16) | rand());
if (*iarg
) srand((int)*iarg
);
return( (float)(rand())/(float)RANDMAX
);
if (*iarg
) srand((int)*iarg
);
return( (double)(rand())/(double)RANDMAX
);