tabs to spaces
This commit is contained in:
parent
d6c3aa5e03
commit
8428f5fd6c
|
|
@ -37,7 +37,7 @@ static unsigned short simple2 (void)
|
||||||
static unsigned short nr(void)
|
static unsigned short nr(void)
|
||||||
{
|
{
|
||||||
unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f));
|
unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f));
|
||||||
return(ulRandom);
|
return(ulRandom);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_randomtest( unsigned short (*keygen)(void) )
|
static void run_randomtest( unsigned short (*keygen)(void) )
|
||||||
|
|
@ -50,14 +50,14 @@ static void run_randomtest( unsigned short (*keygen)(void) )
|
||||||
|
|
||||||
for(i=0;i<rounds;i++)
|
for(i=0;i<rounds;i++)
|
||||||
{
|
{
|
||||||
rnd=keygen();
|
rnd=keygen();
|
||||||
|
|
||||||
for(j=0;j<16;j++)
|
for(j=0;j<16;j++)
|
||||||
{
|
{
|
||||||
if(rnd & 1)
|
if(rnd & 1)
|
||||||
bitcount[j]++;
|
bitcount[j]++;
|
||||||
rnd=rnd>>1;
|
rnd=rnd>>1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,12 +72,12 @@ static void print_bitcount(void)
|
||||||
|
|
||||||
for(i=0;i<16;i++)
|
for(i=0;i<16;i++)
|
||||||
{
|
{
|
||||||
ratio=(float)bitcount[i]/rounds;
|
ratio=(float)bitcount[i]/rounds;
|
||||||
if(fabs(ratio-0.5f)>worst)
|
if(fabs(ratio-0.5f)>worst)
|
||||||
worst=fabs(ratio-0.5f);
|
worst=fabs(ratio-0.5f);
|
||||||
printf("%.2f ",ratio);
|
printf("%.2f ", ratio);
|
||||||
}
|
}
|
||||||
printf(" Worst: %.3f\n",worst);
|
printf(" Worst: %.3f\n", worst);
|
||||||
if(worst>MAX_WORST_ALLOWED) result++;
|
if(worst>MAX_WORST_ALLOWED) result++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ int main(int argc,const char *argv[])
|
||||||
rounds=20000;
|
rounds=20000;
|
||||||
if(argc>1)
|
if(argc>1)
|
||||||
{
|
{
|
||||||
rounds=atoi(argv[1]);
|
rounds=atoi(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Running %d rounds.\n\n",rounds);
|
printf("Running %d rounds.\n\n",rounds);
|
||||||
|
|
@ -113,5 +113,6 @@ int main(int argc,const char *argv[])
|
||||||
printf("Generator: Numerical Recipes\n");
|
printf("Generator: Numerical Recipes\n");
|
||||||
run_randomtest(nr);
|
run_randomtest(nr);
|
||||||
print_bitcount();
|
print_bitcount();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user