diff --git a/c-programming/reverse-ramdisk.c b/c-programming/reverse-ramdisk.c index c8b0669..ff1618b 100644 --- a/c-programming/reverse-ramdisk.c +++ b/c-programming/reverse-ramdisk.c @@ -64,7 +64,7 @@ int tf_alloc(size_t n, size_t type_size) { if (num_temp_files == 0) len_digit = 1; else - len_digit = (size_t) ceil(log((double) num_temp_files + 1.) / log(10.)); + len_digit = (size_t) floor(log10((double) num_temp_files)) + 1; size_t file_path_len = len_digit + strlen("tf_.tmp"); char* file_path = malloc((file_path_len + 1) * sizeof(char)); if (file_path == NULL) {