9 time_t t
= time (NULL
);
13 struct drand48_data data
;
14 unsigned short int buf
[3];
16 srand48 ((long int) t
);
17 for (i
= 0; i
< 50; i
++)
18 if ((d
= drand48 ()) < 0.0 || d
>= 1.0)
20 printf ("drand48 %d %g\n", i
, d
);
24 srand48_r ((long int) t
, &data
);
25 for (i
= 0; i
< 50; i
++)
26 if (drand48_r (&data
, &d
) != 0 || d
< 0.0 || d
>= 1.0)
28 printf ("drand48_r %d %g\n", i
, d
);
32 buf
[2] = (t
& 0xffff0000) >> 16; buf
[1] = (t
& 0xffff); buf
[0] = 0x330e;
33 for (i
= 0; i
< 50; i
++)
34 if ((d
= erand48 (buf
)) < 0.0 || d
>= 1.0)
36 printf ("erand48 %d %g\n", i
, d
);
40 buf
[2] = (t
& 0xffff0000) >> 16; buf
[1] = (t
& 0xffff); buf
[0] = 0x330e;
41 for (i
= 0; i
< 50; i
++)
42 if (erand48_r (buf
, &data
, &d
) != 0 || d
< 0.0 || d
>= 1.0)
44 printf ("erand48_r %d %g\n", i
, d
);
48 srand48 ((long int) t
);
49 for (i
= 0; i
< 50; i
++)
50 if ((l
= lrand48 ()) < 0 || l
> INT32_MAX
)
52 printf ("lrand48 %d %ld\n", i
, l
);
56 srand48_r ((long int) t
, &data
);
57 for (i
= 0; i
< 50; i
++)
58 if (lrand48_r (&data
, &l
) != 0 || l
< 0 || l
> INT32_MAX
)
60 printf ("lrand48_r %d %ld\n", i
, l
);
64 buf
[2] = (t
& 0xffff0000) >> 16; buf
[1] = (t
& 0xffff); buf
[0] = 0x330e;
65 for (i
= 0; i
< 50; i
++)
66 if ((l
= nrand48 (buf
)) < 0 || l
> INT32_MAX
)
68 printf ("nrand48 %d %ld\n", i
, l
);
72 buf
[2] = (t
& 0xffff0000) >> 16; buf
[1] = (t
& 0xffff); buf
[0] = 0x330e;
73 for (i
= 0; i
< 50; i
++)
74 if (nrand48_r (buf
, &data
, &l
) != 0 || l
< 0 || l
> INT32_MAX
)
76 printf ("nrand48_r %d %ld\n", i
, l
);
80 srand48 ((long int) t
);
81 for (i
= 0; i
< 50; i
++)
82 if ((l
= mrand48 ()) < INT32_MIN
|| l
> INT32_MAX
)
84 printf ("mrand48 %d %ld\n", i
, l
);
88 srand48_r ((long int) t
, &data
);
89 for (i
= 0; i
< 50; i
++)
90 if (mrand48_r (&data
, &l
) != 0 || l
< INT32_MIN
|| l
> INT32_MAX
)
92 printf ("mrand48_r %d %ld\n", i
, l
);
96 buf
[2] = (t
& 0xffff0000) >> 16; buf
[1] = (t
& 0xffff); buf
[0] = 0x330e;
97 for (i
= 0; i
< 50; i
++)
98 if ((l
= jrand48 (buf
)) < INT32_MIN
|| l
> INT32_MAX
)
100 printf ("jrand48 %d %ld\n", i
, l
);
104 buf
[2] = (t
& 0xffff0000) >> 16; buf
[1] = (t
& 0xffff); buf
[0] = 0x330e;
105 for (i
= 0; i
< 50; i
++)
106 if (jrand48_r (buf
, &data
, &l
) != 0 || l
< INT32_MIN
|| l
> INT32_MAX
)
108 printf ("jrand48_r %d %ld\n", i
, l
);