Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Miscellaneous Functions


randomx

You can use the randomx function to generate a random number.

double_t randomx (double_t * x);
x
The address of an integer in the range 1 x stored as a floating-point number.
DESCRIPTION
The randomx function is a pseudorandom number generator. The function randomx returns a pseudorandom number in the range of its argument. It uses the iteration formula

x LEFTARROW (75×x)mod(231+-1)

If seed values of x are not integers or are outside the range specified for x, then results are unspecified. A pseudorandom rectangular distribution on the interval (0, 1) can be obtained by dividing the results from randomx by

231+-1 = scalb(31,1)+-1

EXCEPTIONS
The results are unspecified if the value of x is a noninteger or is outside of the range
1 x+-2

SPECIAL CASES
If x is a zero, NaN, or Infinity, the results are unspecified.

EXAMPLES
randomx(1) = any value in the range 1 x+-2 .


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996