jrand48

Generate uniformly distributed pseudorandom number sequences. Returns 48-bit signed, long integers.

Format

#include  <stdlib.h>

long int jrand48  (unsigned short int xsubi[3]);

Arguments

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

Description

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

The function returns signed long integers uniformly distributed over the range of y values, such that -231

The 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 jrand48 function requires that the calling program pass an array as the xsubi argument, which for the first call must be initialized to the initial 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, jrand48 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
Signed, long integers uniformly distributed over the range -231


Previous Page | Next Page | Table of Contents | Index