1.4.3.25 _LIBQ_Q31Rand Function

Generate a _Q31 random number.

Description

_Q31 _LIBQ_Q31Rand (int64_t *pSeed);

Generates a _Q31 pseudo-random value based on the seed supplied as a parameter. The first time this function is called, the seed value must be supplied by the user; this initial seed value can either be constant or random, depending on whether the user wants to generate a repeatable or a non-repeatable pseudo-random sequence.

The function updates the *pSeed value each time it is called. The updated *pSeed value must be passed back to the function with each subsequent call.

Warning: The pseudo-random sequence generated by this function may be insufficient for cryptographic use.

Preconditions

None.

Parameters

pSeed A pointer to the seed value used by the function to generate a pseudo-random sequence.

Returns

_LIBQ_Q31Rand returns a pseudo-random _Q31 value.

_LIBQ_Q31Rand also updates the int64_t *pSeed value.

Remarks

Execution Time (cycles): 32

Program Memory 88 bytes

Example

_// Initialize seed to a constant or random value_

static int64_t randomSeed = 0x7F18BA710E72D4C1;

_Q31 randomValue;

randomValue = _LIBQ_Q31Rand(&randomSeed);

...

randomValue = _LIBQ_Q31Rand(&randomSeed);

C

_Q31 _LIBQ_Q31Rand (int64_t * pSeed );