]> Sergey Matveev's repositories - nnn.git/commitdiff
float is suficient and a _little_ faster in coolsize()
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 5 Mar 2018 03:16:34 +0000 (08:46 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 5 Mar 2018 03:16:34 +0000 (08:46 +0530)
nnn.c

diff --git a/nnn.c b/nnn.c
index 556857448c02a26807b37d55366a9f5b74c31796..dc2b8cfeee3ce1e8d1cfe84136fa9901fdb18b3e 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -1441,7 +1441,7 @@ coolsize(off_t size)
        static char size_buf[12]; /* Buffer to hold human readable size */
        static int i;
 
-       static long double rem;
+       static off_t rem;
        static const double div_2_pow_10 = 1.0 / 1024.0;
 
        i = 0;
@@ -1453,7 +1453,7 @@ coolsize(off_t size)
                ++i;
        }
 
-       snprintf(size_buf, 12, "%.*Lf%c", i, size + rem * div_2_pow_10, U[i]);
+       snprintf(size_buf, 12, "%.*f%c", i, size + (float)rem * div_2_pow_10, U[i]);
        return size_buf;
 }