Subject: bin/2714: ftp(1) reports exponential format numbers
To: None <gnats-bugs@NetBSD.ORG>
From: None <tv@pobox.com>
List: netbsd-bugs
Date: 08/26/1996 17:30:40
>Number:         2714
>Category:       bin
>Synopsis:       ftp(1) reports exponential format numbers
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 26 17:50:01 1996
>Last-Modified:
>Originator:     Todd Vierling
>Organization:
NetBSD Addicts Anonymous
>Release:        1.2_BETA
>Environment:
>Description:
ftp(1) displays elapsed time as a float, and when greater than 3 digits,
as an exponential number.  Slow PPP (14.4k/28.8k etc.) connections often
show such amounts.

>How-To-Repeat:
FTP something for >1000 seconds.  Exponential format number.

2982240 bytes received in 2.16e+03 seconds (1380 bytes/s)

(should read 2160 seconds)

>Fix:
I recommend casting the float to a quad_t just before printing to preserve
the floating point qualities needed for an accurate bytes/s count, but so
that the seconds is shown as a 64 bit integer upon printout.  The
following diff accomplishes this.  (Ponder away...)


*** ftp.c.orig	Mon Aug 26 17:28:23 1996
--- ftp.c	Mon Aug 26 17:28:51 1996
***************
*** 1166,1173 ****
  		s = td.tv_sec + (td.tv_usec / 1000000.);
  #define	nz(x)	((x) == 0 ? 1 : (x))
  		bs = bytes / nz(s);
! 		printf("%ld bytes %s in %.3g seconds (%ld bytes/s)\n",
! 		    bytes, direction, s, bs);
  	}
  }
  
--- 1166,1173 ----
  		s = td.tv_sec + (td.tv_usec / 1000000.);
  #define	nz(x)	((x) == 0 ? 1 : (x))
  		bs = bytes / nz(s);
! 		printf("%ld bytes %s in %qd seconds (%ld bytes/s)\n",
! 		    bytes, direction, (quad_t)s, bs);
  	}
  }
  
>Audit-Trail:
>Unformatted: