2013-05-14 15:11:29 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1984-11-29 14:22:02 +00:00
|
|
|
|
1991-09-04 16:01:22 +00:00
|
|
|
#if !defined(EM_WSIZE)
|
|
|
|
#define EM_WSIZE _EM_WSIZE
|
|
|
|
#endif
|
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
void _randomi(void)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
int i;
|
1985-01-21 12:37:26 +00:00
|
|
|
_setchan(-1);
|
1984-11-29 14:22:02 +00:00
|
|
|
printf("Random number seed (-32768 to 32767) ? ");
|
|
|
|
_readint(&i);
|
1988-07-01 17:30:06 +00:00
|
|
|
_setrand(i);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
void _setrand(int i)
|
1988-07-01 17:30:06 +00:00
|
|
|
{
|
1984-11-29 14:22:02 +00:00
|
|
|
srand(i);
|
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
double _rnd(double d)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
2016-12-12 20:16:32 +00:00
|
|
|
double f;
|
|
|
|
f = (int)rand();
|
|
|
|
return (f /
|
1988-07-01 17:30:06 +00:00
|
|
|
#if EM_WSIZE == 4
|
2016-12-12 20:16:32 +00:00
|
|
|
2147483647.0
|
1988-07-01 17:30:06 +00:00
|
|
|
#else
|
2016-12-12 20:16:32 +00:00
|
|
|
32767.0
|
1988-07-01 17:30:06 +00:00
|
|
|
#endif
|
2016-12-12 20:16:32 +00:00
|
|
|
);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|