erand48

Generate uniformly distributed pseudorandom number sequences. Returns 48-bit nonnegative, double-precision, floating-point values.

Format

#include  <stdlib.h>

double erand48  (unsigned short int xsubi[3]);

Argument

xsubi
An array of three short int, which form a 48-bit integer when concatentated together.

Description

This function generates pseudorandom numbers using the linear congruential algorithm and 48-bit integer arithmetic.

It returns nonnegative, double-precision, floating-point values uniformly distributed over the range of y values, such that, 0.0 < 1.0.

The erand48 function works by generating a sequence of 48-bit integer values, Xi, according to the linear congruential formula:

       Xn+1 = (aXn+c)mod m        n >= 0

The argument m equals 248 , so 48-bit integer arithmetic is performed. Unless you invoke the lcong48 function, the multiplier value a and the addend value c are:

      a = 5DEECE66D16 = 2736731631558

      c = B16 = 138

The erand48 function requires that the calling program pass an array as the xsubi argument. For the first call, the array must be initialized to the value of the pseudorandom number sequence. Unlike the drand48 function, it is not necessary to call an initialization function prior to the first call.

By using different arguments, the erand48 function allows separate modules of a large program to generate several independent sequences of pseudorandom numbers; for example, the sequence of numbers that one module generates does not depend upon how many times the function is called by other modules.

Return Values
A nonnegative, double-precision, floating-point value. 


Previous Page | Next Page | Table of Contents | Index