X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=random.c;h=468a3a5d877cd329801d2546048dd572a14e9bd0;hp=ec99a33456689ff02bd2e4df1e204e53e27ec7b5;hb=b64a7e60a1dd402f89d455271deea29f268e8ad5;hpb=de3ae9b29a64eaf297b44665022665962eba4a14 diff --git a/random.c b/random.c index ec99a33..468a3a5 100644 --- a/random.c +++ b/random.c @@ -55,6 +55,9 @@ u32 get_rand(u32 max) { if(c_ptr>=b_ptr+BUFSIZE) { +#ifdef MORE_PRINTF + printf("getting another %d bytes of random data ...\n",BUFSIZE); +#endif if(read(rand_fd,b_ptr,BUFSIZE*sizeof(u32)) assume random file, end reached */ @@ -63,6 +66,9 @@ u32 get_rand(u32 max) read(rand_fd,b_ptr,BUFSIZE*sizeof(u32)); } c_ptr=b_ptr; +#ifdef MORE_PRINTF + printf("got it!\n"); +#endif } return((u32)(*(c_ptr++)*(max*1.0/((long long unsigned int)URAND_MAX+1)))); @@ -86,5 +92,5 @@ u32 get_rand_reject(u32 max_x,u32 max_y,u32 *graph) if(y<=graph[x]) ok=1; } - return y; + return x; }