123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #include "mconf.h"
- static int sx = 1;
- static int sy = 10000;
- static int sz = 3000;
- static union {
- double d;
- unsigned short s[4];
- } unkans;
-
- int ranwh()
- {
- int r, s;
- r = sx/177;
- s = sx - 177 * r;
- sx = 171 * s - 2 * r;
- if( sx < 0 )
- sx += 30269;
- r = sy/176;
- s = sy - 176 * r;
- sy = 172 * s - 35 * r;
- if( sy < 0 )
- sy += 30307;
- r = sz/178;
- s = sz - 178 * r;
- sz = 170 * s - 63 * r;
- if( sz < 0 )
- sz += 30323;
- return 0;
- }
- int drand( a )
- double *a;
- {
- unsigned short r;
- #ifdef DEC
- unsigned short s, t;
- #endif
- ranwh();
- unkans.d = sx/30269.0 + sy/30307.0 + sz/30323.0;
- r = unkans.d;
- unkans.d -= r;
- unkans.d += 1.0;
- #ifdef UNK
- #else
- ranwh();
- r = sx * sy + sz;
- #endif
- #ifdef DEC
- s = unkans.s[2];
- t = s & 07;
- s &= 0177770;
- s |= (r >> 13) & 07;
- unkans.s[2] = s;
- t |= r << 3;
- unkans.s[3] = t;
- #endif
- #ifdef IBMPC
- unkans.s[0] = r;
- #endif
- #ifdef MIEEE
- unkans.s[3] = r;
- #endif
- *a = unkans.d;
- return 0;
- }
|