Amiga Developer Site by i n n o i d e a | MorphOS | Amiga Developers | Compilers | Documents | Dev-HardFile v1.11 for UAE / real Amiga - readme - shot) | Unique/All Visitors: 77257/570053
Search manual for function in the   
GeekGadgets/random
NAME 

random, srandom, initstate, setstate - random number generator.

SYNOPSIS 


#include <stdlib.h> 


long int random(void); 
void srandom(unsigned int seed);
char *initstate(unsigned int seed, char *state, size_t n);
char *setstate(char *state);


DESCRIPTION 

The random() function uses a non-linear additive feedback random
number generator employing a default table of size 31 long integers to
return successive pseudo-random numbers in the range from 0 to RAND_MAX.
The period of this random number generator is very large, approximately
16*((2**31)-1).


The srandom() function sets its argument as the seed for a new
sequence of pseudo-random integers to be returned by random().
These sequences are repeatable by calling srandom() with the same
seed value.  If no seed value is provided, the random() function 
is automatically seeded with a value of 1.


The initstate() function allows a state array state to
be initialized for use by random().  The size of the state array
n is used by initstate() to decide how sophisticated a
random number generator it should use   the larger the state array,
the better the random numbers will be.  seed is the seed for the
initialization, which specifies a starting point for the random number
sequence, and provides for restarting at the same point.


The setstate() function changes the state array used by the
random() function.  The state array state is used for
random number generation until the next call to initstate()
or setstate().  state must first have been initialized 
using initstate() or be the result of a previous call of
setstate().

RETURN VALUE 

The random() function returns a value between 0 and RAND_MAX.
The srandom() function returns no value.  The initstate() 
and setstate() functions return a pointer to the previous state 
array, or NULL on error.

ERRORS 

EINVAL 
A state array of less than 8 bytes was specified to initstate().

NOTES 

Current "optimal" values for the size of the state array n are
8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to
the nearest known amount.  Using less than 8 bytes will cause an
error.

CONFORMING TO 

BSD 4.3

SEE ALSO 

rand(3),
srand(3)


20040327172814 - LouiSe - for (GeekGadgets/random)
Example #1 is a random() implementation...

Logo by Emeric/SH
GeekGadgets/random

Example #1 Download / View

Functions with "r":
radix.h
radix_protos.h
raise
rand
random
ranlib.h
raw_cb.h
raw_cb_protos.h
raw_ip_protos.h
raw_usrreq_protos.h
rcmd
rcs.h
re_comp
re_exec
read
readdir
readlink
readv
realloc
realpath
reboot
recno
recv
recvfrom
recvmsg
reg.h
regcomp
regerror
regex
regex.h
regexec
regexp.h
regfree
register
registerrpc
remove
remque
rename
res_comp.c
res_debug.c
res_init
res_init.c
res_mkquery
res_mkquery.c
res_query
res_query.c
res_querydomain
res_search
res_send
res_send.c
resolv.h
resolv_extras.h
resolver
resource.h
return
rewind
rewinddir
rex.x
rindex
rint
rintf
rintl
rmdir
rnusers.x
round
roundf
roundl
route.h
routed.h
routing
rpc
rpc.h
rpc_msg.h
rpcv2.h
rquota.x
rresvport
rstat.c
rstat.x
rstat_proc.c
rtnetlink
rtsock_protos.h
ruserok
rwhod.h

Last 15 uploaded Examples:

20071229151342 AmiSSL/X509_STORE_CTX_cleanup
20070708011052 GeekGadgets/getlogin
20060705053954 AmigaOS/OpenWorkbenchObjectA
20050801035639 SDL/SDL_Surface
20050727092732 BlitzBasic/LSL
20050718102843 SDL/SDL_WarpMouse
20050718072844 GeekGadgets/fread
20050714051528 SDL/SDL_ActiveEvent
20050714051514 SDL/SDL_ActiveEvent
20050701171401 GeekGadgets/errno
20050701171347 GeekGadgets/errno
20050627101951 SDL/SDL_FreeSurface
20050623152729 GeekGadgets/fork
20050619153102 GeekGadgets/tcdrain
20050615182849 AmigaOS/OpenScreen

Last 25 posts:

20050613235812 SDL/SDL_SetGammaRamp
20050526065000 AmiTCP/unistd.h
20050413041558 AmiSSL/X509_STORE_set_default_paths
20050409155750 AmigaDOS/Status
20050129230614 MUI/Calendar.mcc
20050128185620 GeekGadgets/hstrerror
20041126154558 BlitzBasic/LoadBank
20041123170704 GeekGadgets/gcvt
20041105222909 AmigaOS/CheckSignal
20040712190839 SDL/SDL_SetVideoMode
20040627090529 SDL/SDL_Init
20040519133228 GeekGadgets/fork
20040407124555 AmigaOS/AllocMem
20040403101120 GeekGadgets/inet_ntoa
20040327172814 GeekGadgets/random
20040327172714 GeekGadgets/srandom
20040313211937 BlitzBasic/ANALYZEDISK
20040303135237 GeekGadgets/mktemp
20040301131355 GeekGadgets/realpath
20040301123615 GeekGadgets/gcvt
20040301114000 GeekGadgets/htonl
20040301100209 GeekGadgets/realpath
20040229095437 GeekGadgets/time
20040211132618 GeekGadgets/getpid
20040209102818 AmigaOS/OpenWindow




Amiga.sf
AMIGIFT

Locations of visitors to this page

Page took 0.791635 seconds to load.