1 --- rand48.h.orig 2003-05-20 15:21:02.000000000 -0700
2 +++ rand48.h 2005-11-03 14:06:17.000000000 -0800
7 -void _dorand48(unsigned short[3]);
9 #define RAND48_SEED_0 (0x330e)
10 #define RAND48_SEED_1 (0xabcd)
11 #define RAND48_SEED_2 (0x1234)
13 #define RAND48_MULT_2 (0x0005)
14 #define RAND48_ADD (0x000b)
16 +typedef unsigned long long uint48;
18 +extern uint48 _rand48_seed;
19 +extern uint48 _rand48_mult;
20 +extern uint48 _rand48_add;
22 +#define TOUINT48(x,y,z) \
23 + ((uint48)(x) + (((uint48)(y)) << 16) + (((uint48)(z)) << 32))
25 +#define RAND48_SEED TOUINT48(RAND48_SEED_0, RAND48_SEED_1, RAND48_SEED_2)
26 +#define RAND48_MULT TOUINT48(RAND48_MULT_0, RAND48_MULT_1, RAND48_MULT_2)
28 +#define LOADRAND48(l,x) \
29 + (l) = TOUINT48((x)[0], (x)[1], (x)[2])
31 +#define STORERAND48(l,x) \
32 + (x)[0] = (unsigned short)(l); \
33 + (x)[1] = (unsigned short)((l) >> 16); \
34 + (x)[2] = (unsigned short)((l) >> 32)
36 +#define _DORAND48(l) \
37 + (l) = (l) * _rand48_mult + _rand48_add
39 +#define DORAND48(l,x) \
47 + * Optimization for speed: avoid int-to-double conversion. Assume doubles
48 + * are IEEE-754 and insert the bits directly. To normalize, the (1 << 52)
49 + * is the hidden bit, which the first set bit is shifted to.
51 +#define ERAND48_BEGIN \
53 + union IEEEd2bits ieee; \
54 + unsigned long long l; \
58 +#define ERAND48_END(x) \
59 + u.l = ((x) & 0xffffffffffffULL); \
63 + for(s = 0; !(u.l & (1LL << 52)); s++, u.l <<= 1) {} \
64 + u.ieee.bits.exp = 1022 - s; \
67 #endif /* _RAND48_H_ */