cnfsstat rounding trouble

Florian Weimer fw at deneb.enyo.de
Sun May 23 17:21:59 UTC 2004


* Christoph Biedl:

> How to fix:
> The C-style make-me-double '(1.0 * $free)/(1.0 * $len)' does not help, a
> workaround is to eval the variables before doing the computations:

Here's my fix which is a bit more perlish:

--- /usr/lib/news/bin/cnfsstat  2004-01-24 16:49:12.000000000 +0000
+++ cnfsstat    2004-05-23 17:21:07.000000000 +0000
@@ -279,14 +279,14 @@
        $name =~ s/\0//g;
        syslog ('notice', '%s Buffer %s, len: %d  Mbytes, used: %.2f Mbytes (%4.1f%%) %3d cycles',
                $logline, $name, $len / (1024 * 1024), $free / (1024 * 1024),
-               100 * $free/$len, $cyclenum);
+               100 * "$free"/"$len", $cyclenum);
        return 0;
     }
 
     $name =~ s/\0//g;
     print " Buffer $name, size: ", &human_readable($len, 4);
     print ", position: ", &human_readable($free, 4);
-    printf("  %.2f cycles\n", $cyclenum + $free/$len);
+    printf("  %.2f cycles\n", $cyclenum + "$free"/"$len");
     my ($when, $ago) = &make_time($update);
     print "  Newest: $when, $ago ago\n";
 

-- 
Current mail filters: many dial-up/DSL/cable modem hosts, and the
following domains: bigpond.com, di-ve.com, hotmail.com, jumpy.it,
libero.it, netscape.net, postino.it, simplesnet.pt, spymac.com,
tatanova.com, tiscali.co.uk, tiscali.cz, tiscali.it, voila.fr, yahoo.com.


More information about the inn-workers mailing list