\chapter{Random Number Generation}
Converse includes support for random number generation using a 64-bit Linear Congruential Generator (LCG). The user can choose between using a supplied default stream shared amonst all chares on the processor, or creating a private stream. Note that there is a limit on the number of private streams, which at the the time of writing was 15,613.
\function{struct CrnStream;}
\index{CrnStream}
\desc{This structure contains the current state of a random number stream. The user is responsible for allocating the memory for this structure.}
\section{Default Stream Calls}
\function{void CrnSrand(int seed);}
\index{CrnSrand}
\desc{Seeds the default randon number generator with {\tt seed}.}
\function{int CrnRand(void);}
\index{CrnRand}
\desc{Returns the next random number in the default stream as an integer.}
\function{int CrnDrand(void);}
\index{CrnDrand}
\desc{Returns the next random number in the default stream as a double.}
\section{Private Stream Calls}
\function{void CrnInitStream(CrnStream *dest, int seed, int type);}
\index{CrnInitStream}
\desc{Initializes a new stream with its initial state stored in {\tt dest}. The user must supply a seed in {\tt seed}, as well as the {\tt type} of the stream, where the {\tt type} can be 0, 1, or 2.}
\function{double CrnDouble(CrnStream *genptr);}
\index{CrnDouble}
\desc{Returns the next random number in the stream whose state is given by {\tt genptr}; the number is returned as a double.}
\function{double CrnInt(CrnStream *genptr);}
\index{CrnInt}
\desc{Returns the next random number in the stream whose state is given by {\tt genptr}; the number is returned as an integer.}
\function{double CrnFloat(CrnStream *genptr);}
\index{CrnFloat}
\desc{Returns the next random number in the stream whose state is given by {\tt genptr}; the number is returned as a float. (Note: This function is exactly equivalent to {\tt (float) CrnDouble(genptr); }.) }