home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 6
/
Aminet 6 - June 1995.iso
/
Aminet
/
dev
/
gcc
/
libnixV0_8.lha
/
gnu
/
libnix-sources.lha
/
sources
/
amiga
/
misc
/
RangeRand.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1994-12-12
|
314 b
|
19 lines
#include <exec/types.h>
ULONG RangeSeed;
ULONG RangeRand(ULONG maxValue)
{ ULONG a=RangeSeed;
UWORD i=maxValue-1;
do
{ ULONG b=a;
a<<=1;
if((LONG)b<=0)
a^=0x1d872b41;
}while(i>>=1);
RangeSeed=a;
if((UWORD)maxValue)
return (UWORD)((UWORD)a*(UWORD)maxValue>>16);
return (UWORD)a;
}