home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
canada-remote-systems
/
cpower
/
random.seq
< prev
next >
Wrap
Text File
|
2019-04-13
|
1KB
|
26 lines
/**************************************/
/* RAND: RETURNS RANDOM VALUE */
/* BETWEEN 'LO' AND 'HI'. */
/* */
/* ╫RITTEN 88/04 BY ╙TEVE ┬OYKO */
/* ╔NFINITY ┼NTERPRISES */
/**************************************/
UNSIGNED RAND (LO,HI)
UNSIGNED LO,HI;
█
FLOAT F;
UNSIGNED RETVAL;
FLOAT RANGE;
/* ├HECK FOR INCORRECT PARAMETERS */
IF (LO >= HI) RETURN (LO);
RANGE = ((FLOAT) HI) - ((FLOAT) LO);
F = ((FLOAT) RANDOM ()) / 65535.0;
RETVAL = (UNSIGNED) (F * RANGE);
RETVAL += LO;
RETURN (RETVAL);
▌