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/srandom
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)


20040327172714 - LouiSe - for (GeekGadgets/srandom)
Example #1 is an srandom() implementation...

Logo by Emeric/SH
GeekGadgets/srandom

Example #1 Download / View

Functions with "s":
sana2.h
sana2arp.h
sana2config.h
sana2errno.h
sana2request.h
sana2specialstats.h
sana2tags.h
sbrk
scandir
scanf
sched_get_priority_max
sched_get_priority_min
sched_getparam
sched_getscheduler
sched_rr_get_interval
sched_setparam
sched_setscheduler
sched_yield
search.h
seed48
seekdir
select
select_tut
sem.h
semctl
semget
semop
send
sendfile
sendmsg
sendto
setbuf
setbuffer
setcontext
setdomainname
setegid
setenv
seteuid
setfsent
setfsgid
setfsuid
setgid
setgrent
setgroups
sethostent
sethostid
sethostname
setitimer
setjmp
setjmp.h
setkey
setlinebuf
setlocale
setlogmask
setmntent
setnetent
setpgid
setpgrp
setpriority
setprotoent
setpwent
setregid
setresgid
setresuid
setreuid
setrlimit
setrpcent
setservent
setsid
setsockopt
setstate
settimeofday
setuid
setup
setusershell
setutent
setutxent
setvbuf
sgetmask
sgtty.h
shm.h
shmat
shmctl
shmdt
shmget
shmop
short
shutdown
sigaction
sigaddset
sigaltstack
sigblock
sigdelset
sigemptyset
sigfillset
siggetmask
siginterrupt
sigismember
siglongjmp
sigmask
signal
signal.h
signed
sigpause
sigpending
sigprocmask
sigreturn
sigsetjmp
sigsetmask
sigsetops
sigsuspend
sigvec
sin
sinh
sizeof
slcompress.h
sleep
sm_inter.x
snprintf
sockargs.h
socket
socket.h
socket_inlines.h
socket_lib.fd
socket_pragmas.h
socket_protos.h
socketbasetags.h
socketcall
socketpair
socketvar.h
sockio.h
spray.x
sprintf
sqrt
srand
srand48
srandom
sscanf
ssetmask
stab.def
stab.h
stabs.h
stat
stat.h
statfs
static
stdarg
stdarg.h
stdc.h
stddef.h
stderr
stdin
stdio
stdio.h
stdio_ext
stdlib.h
stdout
stime
stpcpy
stpncpy
strcasecmp
strcat
strchr
strcmp
strcoll
strcpy
strcspn
strdup
strdupa
strerror
strerror_r
strfmon
strfry
strftime
string
string.h
strings.h
strlen
strncasecmp
strncat
strncmp
strncpy
strndup
strndupa
strnlen
strpbrk
strptime
strrchr
strsep
strsignal
strspn
strstr
strtod
strtof
strtok
strtok_r
strtol
strtold
strtoll
strtoul
strtoull
struct
struct.h
strverscmp
strxfrm
stty
subr_prf.c
subr_prf_protos.h
svc.h
svc_auth.h
svc_destroy
svc_freeargs
svc_getargs
svc_getcaller
svc_getreq
svc_getreqset
svc_register
svc_run
svc_sendreply
svc_unregister
svcerr_auth
svcerr_decode
svcerr_noproc
svcerr_noprog
svcerr_progvers
svcerr_systemerr
svcerr_weakauth
svcfd_create
svcraw_create
svctcp_create
svcudp_bufcreate
svcudp_create
swab
swapcontext
swapoff
swapon
switch
swprintf
symlink
sync
synch.h
syscall.def
syscall.h
syscalls
sysconf
sysctl
sysexits.h
sysfs
sysinfo
syslimits.h
syslog
syslog.h
system
systm.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.662254 seconds to load.