/[inetutils]/inetutils/ping/ping_echo.c
ViewVC logotype

Diff of /inetutils/ping/ping_echo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by ams, Mon Apr 29 21:07:54 2002 UTC revision 1.7 by gray, Wed Jan 15 08:32:40 2003 UTC
# Line 43  Line 43 
43  #include <stdio.h>  #include <stdio.h>
44  #include <ctype.h>  #include <ctype.h>
45  #include <errno.h>  #include <errno.h>
 #include <math.h>  
46  #include <limits.h>  #include <limits.h>
47    
48  #include "getopt.h"  #include "getopt.h"
# Line 583  tvsub (out, in) Line 582  tvsub (out, in)
582          out->tv_sec -= in->tv_sec;          out->tv_sec -= in->tv_sec;
583  }  }
584    
585    double
586    nsqrt (double a, double prec)
587    {
588      double x0, x1;
589      
590      if (a < 0)
591        return 0;
592      if (a < prec)
593        return 0;
594      x1 = a/2;
595      do
596        {
597          x0 = x1;
598          x1 = (x0 + a/x0) / 2;
599        }
600      while (fabs (x1 - x0) > prec);
601    
602      return x1;
603    }
604    
605  int  int
606  echo_finish ()  echo_finish ()
# Line 596  echo_finish () Line 614  echo_finish ()
614        double vari = ping_stat->tsumsq / total - avg * avg;        double vari = ping_stat->tsumsq / total - avg * avg;
615    
616        printf ("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n",        printf ("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n",
617               ping_stat->tmin,                ping_stat->tmin,
618               avg,                avg,
619               ping_stat->tmax,                ping_stat->tmax,
620               sqrt (vari));                nsqrt (vari, 0.0005));
621      }      }
622    exit (ping->ping_num_recv == 0);    exit (ping->ping_num_recv == 0);
623  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26