Fix potential float screwup in scp percentage indicator. (Don't
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 8 Sep 2001 15:16:30 +0000 (15:16 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 8 Sep 2001 15:16:30 +0000 (15:16 +0000)
compute (100*a)/b. Instead compute 100*(a/b), because that way
there's no chance that 100*a will become inexact enough to fail to
yield 100 when a==b.)

git-svn-id: svn://svn.tartarus.org/sgt/putty@1254 cda61777-01e9-0310-a592-d414129be87e

scp.c

diff --git a/scp.c b/scp.c
index 5537ef3..aca1cf3 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -649,7 +649,7 @@ static void print_stats(char *name, unsigned long size, unsigned long done,
        sprintf(etastr, "%02ld:%02ld:%02ld",
                eta / 3600, (eta % 3600) / 60, eta % 60);
 
-       pct = (int) (100.0 * (float) done / size);
+       pct = (int) (100 * (done * 1.0 / size));
 
        len = printf("\r%-25.25s | %10ld kB | %5.1f kB/s | ETA: %8s | %3d%%",
                     name, done / 1024, ratebs / 1024.0, etastr, pct);