**Subsections**

# 7 . 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 amongst 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 time of writing was 15,613.

struct CrnStream;

This structure contains the current state of a random number stream. The user is responsible for allocating the memory for this structure.

# 7 . 1 Default Stream Calls

void CrnSrand(int seed);

Seeds the default random number generator with
```
seed
```

.

int CrnRand(void);

Returns the next random number in the default stream as an integer.

int CrnDrand(void);

Returns the next random number in the default stream as a double.

# 7 . 2 Private Stream Calls

void CrnInitStream(CrnStream *dest, int seed, int type);

Initializes a new stream with its initial state stored in
```
dest
```

. The user must supply a seed in
```
seed
```

, as well as the
```
type
```

of the stream, where the
```
type
```

can be 0, 1, or 2.

double CrnDouble(CrnStream *genptr);

Returns the next random number in the stream whose state is given by
```
genptr
```

; the number is returned as a double.

double CrnInt(CrnStream *genptr);

Returns the next random number in the stream whose state is given by
```
genptr
```

; the number is returned as an integer.

double CrnFloat(CrnStream *genptr);

Returns the next random number in the stream whose state is given by
```
genptr
```

; the number is returned as a float. (Note: This function is exactly equivalent to
```
(float) CrnDouble(genptr);
```

.)