From 8428f5fd6c88a07896e114e64da18d6e951ce581 Mon Sep 17 00:00:00 2001 From: Radim Kolar Date: Mon, 8 Jul 2024 12:14:15 +0200 Subject: [PATCH] tabs to spaces --- tests/randomcheck.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/randomcheck.c b/tests/randomcheck.c index 3bc0086..d605b60 100644 --- a/tests/randomcheck.c +++ b/tests/randomcheck.c @@ -37,7 +37,7 @@ static unsigned short simple2 (void) static unsigned short nr(void) { unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f)); - return(ulRandom); + return(ulRandom); } static void run_randomtest( unsigned short (*keygen)(void) ) @@ -50,14 +50,14 @@ static void run_randomtest( unsigned short (*keygen)(void) ) for(i=0;i>1; - } + rnd=keygen(); + + for(j=0;j<16;j++) + { + if(rnd & 1) + bitcount[j]++; + rnd=rnd>>1; + } } } @@ -72,12 +72,12 @@ static void print_bitcount(void) for(i=0;i<16;i++) { - ratio=(float)bitcount[i]/rounds; - if(fabs(ratio-0.5f)>worst) - worst=fabs(ratio-0.5f); - printf("%.2f ",ratio); + ratio=(float)bitcount[i]/rounds; + if(fabs(ratio-0.5f)>worst) + worst=fabs(ratio-0.5f); + printf("%.2f ", ratio); } - printf(" Worst: %.3f\n",worst); + printf(" Worst: %.3f\n", worst); if(worst>MAX_WORST_ALLOWED) result++; } @@ -87,11 +87,11 @@ int main(int argc,const char *argv[]) rounds=20000; if(argc>1) { - rounds=atoi(argv[1]); + rounds=atoi(argv[1]); } printf("Running %d rounds.\n\n",rounds); - + result=0; #ifdef HAVE_SRANDOMDEV srandomdev(); @@ -113,5 +113,6 @@ int main(int argc,const char *argv[]) printf("Generator: Numerical Recipes\n"); run_randomtest(nr); print_bitcount(); + return result; }