Simplified math in ptransfer() to avoid destroying bits (and somethings
authorCraig Leres <leres@ucbvax.Berkeley.EDU>
Fri, 4 May 1984 06:38:07 +0000 (22:38 -0800)
committerCraig Leres <leres@ucbvax.Berkeley.EDU>
Fri, 4 May 1984 06:38:07 +0000 (22:38 -0800)
coming up with negative transfer rates).

SCCS-vsn: usr.bin/ftp/ftp.c 4.12

usr/src/usr.bin/ftp/ftp.c

index ac18fe1..6f3ed61 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)ftp.c      4.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftp.c      4.12 (Berkeley) %G%";
 #endif
 
 #include <sys/param.h>
 #endif
 
 #include <sys/param.h>
@@ -556,15 +556,14 @@ ptransfer(direction, bytes, t0, t1)
        struct timeval *t0, *t1;
 {
        struct timeval td;
        struct timeval *t0, *t1;
 {
        struct timeval td;
-       long ms;
-       float bs;
+       float s, bs;
 
        tvsub(&td, t1, t0);
 
        tvsub(&td, t1, t0);
-       ms = (td.tv_sec * 1000) + (td.tv_usec / 1000);
+       s = td.tv_sec + (td.tv_usec / 1000000.);
 #define        nz(x)   ((x) == 0 ? 1 : (x))
 #define        nz(x)   ((x) == 0 ? 1 : (x))
-       bs = ((bytes * NBBY * 1000) / (float) nz(ms)) / NBBY;
-       printf("%ld bytes %s in %d.%02d seconds (%.2g Kbytes/s)\n",
-               bytes, direction, td.tv_sec, td.tv_usec / 10000, bs / 1024.);
+       bs = bytes / nz(s);
+       printf("%ld bytes %s in %.2g seconds (%.2g Kbytes/s)\n",
+               bytes, direction, s, bs / 1024.);
 }
 
 tvadd(tsum, t0)
 }
 
 tvadd(tsum, t0)