/* file prand2.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif

double prand2(boolean *first_time)
/* Returns a random probability (flat distribution), using "random()". */
/* For a slightly faster but shorter period function, see prand1.c     */
/* Uses random(), whose max value is (2**31)-1.                        */
{double rx;
 static double RANDOM_MAX;
 if (*first_time) {RANDOM_MAX = pow(2.0,31.0)-1.0; *first_time=F;}
 rx = (double)random()/(RANDOM_MAX+1);
 return rx;
}
