random

random

Author Joep Suijs, Copyright © 2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides a (decent) random function.
The formula is provided by *the* George Marsaglia.
(see http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2008-03/msg03691.html) 



/* initialize with any 32-bit seed x and any 32-bit y not 0 */
static unsigned long x=2282008, y=362436069;
#define sK ( x=69069*x+123, y^=y<<13, y^=y>>17, y^=y<<5, x+y )



function random_byte returns an 8-bit random number
function random_word returns a 16-bit random number
functon dice         returns a number from 1 to 6



Note: this library will recreate the same sequence. If this is undesired, assign a
      different (non-zero!) startup-value to _rndx and/or _rndy at startup.



Note2: If you don't care about random quality and want to save a few processor cycles or
       memory bytes, define random_downgrade to select a basic random algorithm.


Sources

Interface Copyright (C) 2005 Stef Mientki


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_random.jal
16f72316f723_random.jal
16f7316f73_random.jal
16f87716f877_random.jal
16f877a16f877a_random.jal
16f8816f88_random.jal
18f14k5018f14k50_random.jal
18f245018f2450_random.jal
18f252018f2520_random.jal
18f255018f2550_random.jal
18f262018f2620_random.jal
18f45218f452_random.jal
18f455018f4550_random.jal
18f462018f4620_random.jal
18f67j5018f67j50_random.jal