If no epigrams are defined yet, the arguments to printf() contain
a division by zero which results in output like:
average number of epigrams per file -nan
average number of tags per epigram. -nan
average number of tag recurrence... -nan
This is not a wrong per se, but it seems to be safer to special case
this and print zero.
printf("number of tags..................... %5lu\n", num_tags);
printf("number of unique tags.............. %5u\n", num_unique_tags);
printf("average number of epigrams per file %8.02f\n",
printf("number of tags..................... %5lu\n", num_tags);
printf("number of unique tags.............. %5u\n", num_unique_tags);
printf("average number of epigrams per file %8.02f\n",
- (float)num_epis / num_epi_files);
- printf("average number of tags per epigram. %8.02f\n",
- (float)num_tags / num_epis);
- printf("average number of tag recurrence... %8.02f\n",
- (float)num_tags / num_unique_tags);
+ num_epi_files > 0? (float)num_epis / num_epi_files : 0);
+ printf("average number of tags per epigram. %8.02f\n", num_epis > 0?
+ (float)num_tags / num_epis : 0);
+ printf("average number of tag recurrence... %8.02f\n", num_unique_tags > 0?
+ (float)num_tags / num_unique_tags : 0);
if (verbose) {
printf("\nlinear hashing statistics:\n%s\n", lh_stats);
free(lh_stats);
if (verbose) {
printf("\nlinear hashing statistics:\n%s\n", lh_stats);
free(lh_stats);