ack/lang/basic/lib/random.c

33 lines
381 B
C
Raw Normal View History

#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
_randomi()
1984-11-29 14:22:02 +00:00
{
int i;
_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
}
1988-07-01 17:30:06 +00:00
_setrand(i)
1984-11-29 14:22:02 +00:00
int i;
1988-07-01 17:30:06 +00:00
{
1984-11-29 14:22:02 +00:00
srand(i);
}
double _rnd(d) double d;
{
double f; f= (int) rand();
1988-07-01 17:30:06 +00:00
return(f/
#if EM_WSIZE == 4
2147483647.0
#else
32767.0
#endif
);
1984-11-29 14:22:02 +00:00
}