123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <ieee754.h>
- #include <stdlib.h>
- #include <limits.h>
- extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer);
- int erand48_r (xsubi, buffer, result)
- unsigned short int xsubi[3];
- struct drand48_data *buffer;
- double *result;
- {
- union ieee754_double temp;
-
- if (__drand48_iterate (xsubi, buffer) < 0)
- return -1;
-
- temp.ieee.negative = 0;
- temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
- temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12);
- temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
-
- *result = temp.d - 1.0;
- return 0;
- }
|