bin/52324: formatting of RTT wrong in ping6

David G. Lawrence dg at
Fri May 16 06:20:10 PDT 2003

>Number:         52324
>Category:       bin
>Synopsis:       formatting of RTT wrong in ping6
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 16 06:20:07 PDT 2003
>Originator:     David G. Lawrence
>Release:        FreeBSD 4.8-STABLE i386
Download Technologies, Inc.
System: FreeBSD 4.8-STABLE FreeBSD 4.8-STABLE #0: Tue Apr 29 08:52:57 PDT 2003 dg at i386

The output format specifier for the round-trip time in ping6 should be
changed to %.3f instead of %g since %g doesn't accurately represent the
precision of the number being output. In particular, %g truncates trailing
zeroes. 0.01 ms does not mean the same thing as 0.010 ms. Although they
are numerically identical, they do not have the same precision. This was
fixed by me in IPv4 ping in rev 1.2, almost 9 years ago.
Use IPv6 and ping a host. Notice occasional truncated precision when the
RTT ends in one or more zeroes.

Index: ping6.c
RCS file: /home/ncvs/src/sbin/ping6/ping6.c,v
retrieving revision
diff -c -r1.4.2.10 ping6.c
*** ping6.c	9 Dec 2002 03:04:44 -0000
--- ping6.c	16 May 2003 13:05:33 -0000
*** 1481,1487 ****
  			if (timing)
! 				(void)printf(" time=%g ms", triptime);
  			if (dupflag)
  			/* check the data */
--- 1481,1487 ----
  			if (timing)
! 				(void)printf(" time=%.3f ms", triptime);
  			if (dupflag)
  			/* check the data */

More information about the freebsd-bugs mailing list