diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-12-06 06:19:54 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-12-06 06:19:54 -0500 |
| commit | 36fb57d1b9f52c61615cc202eb01b92044b7d145 (patch) | |
| tree | d73c84d4ff623ed1902ea03561a428eb096f4144 | |
| parent | f9049f5f3e5e6fbd922e2f5575b45ec1e9c336ea (diff) | |
| download | alftools-36fb57d1b9f52c61615cc202eb01b92044b7d145.tar.gz | |
alf: percent().
| -rw-r--r-- | src/alf.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -180,6 +180,10 @@ void convert_eols(void) { } } +int percent(unsigned int out, unsigned int in) { + return 100 - (int)((float)out / (float)in * 100.0); +} + void crunch_file(const char *filename_arg) { strncpy(in_filename, filename_arg, PATH_MAX); @@ -242,8 +246,7 @@ void crunch_file(const char *filename_arg) { if(opt_verbose) { printf(" %u/%u (%d%%)\n", - input_len, output_len, - 100 - (int)((float)output_len / (float)input_len * 100.0)); + input_len, output_len, percent(output_len, input_len)); } total_in += input_len; @@ -351,7 +354,7 @@ int main(int argc, char **argv) { printf("Compressed %d file%s: ", file_count, file_count == 1 ? "" : "s"); printf("%u/%u (%d%%)\n", total_in, total_out, - 100 - (int)((float)total_out / (float)total_in * 100.0)); + percent(total_out, total_in)); print_elapsed_time(); if(backup_msg) { printf("Backed up old '%s' to '%s~'.\n", out_filename, out_filename); |
