2 * random.c - functions to get random values
12 /* global and extern variables */
13 extern u32 sum_z_cells;
16 /* return random integer between 0 - max-1 */
20 if(read(random_fd,&rand_int,4)!=4)
22 puts("failed reading 4 bytes of random data");
25 /* cells numbered 0...max-1 */
26 return((u32)(rand_int*(max*1.0/URAND_MAX)));
29 /* get z value (linear growth of probability with depths) */
30 u32 rand_get_lgp(int slope_nel,int start_nel)
34 z=rand_get(sum_z_cells)+1; /* +1 as rand_get returns values 0...max-1 */
36 z-=(start_nel+i*slope_nel);
39 return(i-1); /* return values 0...z_cell-1 */