STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
← STM32duino documentation
Loading...
Searching...
No Matches
WMath.cpp File Reference

Pseudo-random number functions: randomSeed() and random(). More...

#include "stdlib.h"
#include "stdint.h"

Functions

void randomSeed (unsigned long dwSeed)
 Seed the pseudo-random number generator.
 
long random (long howbig)
 Return a pseudo-random number in the range [0, howbig).
 
long random (long howsmall, long howbig)
 Return a pseudo-random number in the range [howsmall, howbig).
 

Detailed Description

Pseudo-random number functions: randomSeed() and random().

Function Documentation

◆ random() [1/2]

long random ( long  howbig)

Return a pseudo-random number in the range [0, howbig).

Parameters
howbigUpper bound, exclusive. 0 returns 0.
Returns
Pseudo-random number.

◆ random() [2/2]

long random ( long  howsmall,
long  howbig 
)

Return a pseudo-random number in the range [howsmall, howbig).

Parameters
howsmallLower bound, inclusive. Returned directly if it is not below howbig.
howbigUpper bound, exclusive.
Returns
Pseudo-random number.

◆ randomSeed()

void randomSeed ( unsigned long  dwSeed)

Seed the pseudo-random number generator.

A seed of 0 is ignored.

Parameters
dwSeedSeed value.