RAND Class Reference

#include "rand.h"

Public Member Functions

RAND (uint64_t seed=0)
uint32_t draw (uint32_t max)
uint32_t draw (uint32_t min, uint32_t max)
uint32_t count (void)
RAND (uint64_t seed=0)
uint32_t draw (uint32_t max)
uint32_t draw (uint32_t min, uint32_t max)

Detailed Description

Constructor & Destructor Documentation

RAND() [1/2]

RAND::RAND ( uint64_t seed = 0 )
inline
48 : seed (seed | 1), num (0)
49 {}

RAND() [2/2]

RAND::RAND ( uint64_t seed = 0 )
inline
46 : seed (seed | 1)
47 {}

Member Function Documentation

count()

uint32_t RAND::count ( void )
inline
88 {
89return num;
90 }

draw() [1/4]

uint32_t RAND::draw ( uint32_t max )
inline
Examples
cpp50Example_main.cpp.
56 {
57 uint32_t val;
58if (max >= 0X7FFFFFFFFFFFFFFFULL)
59 {
60do
61 {
62 val = next ();
63 } while (val > max);
64 }
65else
66 {
67 uint64_t frac = 0X7FFFFFFFFFFFFFFFULL / (max + 1ULL);
68do
69 {
70 val = (next () >> 1) / frac;
71 } while (val > max);
72 }
73
74return val;
75 }

Referenced by draw().

Here is the caller graph for this function:

draw() [2/4]

uint32_t RAND::draw ( uint32_t max )
inline
54 {
55 uint32_t val;
56if (max >= 0X7FFFFFFFUL)
57 {
58do
59 {
60 val = next ();
61 } while (val > max);
62 }
63else
64 {
65 uint32_t frac = 0X7FFFFFFFUL / (max + 1UL);
66do
67 {
68 val = (next () >> 1) / frac;
69 } while (val > max);
70 }
71
72return val;
73 }

draw() [3/4]

uint32_t RAND::draw ( uint32_t min,
uint32_t max
)
inline
82 {
83return draw (max - min) + min;
84 }

References draw().

Here is the call graph for this function:

draw() [4/4]

uint32_t RAND::draw ( uint32_t min,
uint32_t max
)
inline
80 {
81return draw (max - min) + min;
82 }

References draw().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
uint32_t draw(uint32_t max)
Definition: cpp50Example/rand.h:55