1:
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: #include "rand48.h"
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29: void
30: __dorand48_r(unsigned short xseed[3], struct rand48_data *buffer)
31: {
32: unsigned long accu;
33: unsigned short temp[2];
34:
35: accu = (unsigned long) buffer->mult[0] * (unsigned long) xseed[0] +
36: (unsigned long) buffer->add;
37: temp[0] = (unsigned short) accu;
38: accu >>= sizeof(unsigned short) * 8;
39: accu += (unsigned long) buffer->mult[0] * (unsigned long) xseed[1] +
40: (unsigned long) buffer->mult[1] * (unsigned long) xseed[0];
41: temp[1] = (unsigned short) accu;
42: accu >>= sizeof(unsigned short) * 8;
43: accu += buffer->mult[0] * xseed[2] + buffer->mult[1] * xseed[1] + buffer->mult[2] * xseed[0];
44: xseed[0] = temp[0];
45: xseed[1] = temp[1];
46: xseed[2] = (unsigned short) accu;
47: }