Date: Mon, 29 Oct 2001 19:56:48 +0200 From: Giorgos Keramidas <charon@labs.gr> To: Dag-Erling Smorgrav <des@ofug.org> Cc: "Andrew R. Reiter" <arr@watson.org>, Luigi Rizzo <rizzo@aciri.org>, Josef Karthauser <joe@FreeBSD.ORG>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: ipfw.c -- (was: cvs commit: src/sys/netinet ip_fw.h) Message-ID: <20011029195648.G23264@hades.hell.gr> In-Reply-To: <xzp4roiqzrd.fsf@flood.ping.uio.no> References: <Pine.NEB.3.96L.1011029010151.33440A-100000@fledge.watson.org> <xzp4roiqzrd.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 29, 2001 at 03:36:38PM +0100, Dag-Erling Smorgrav wrote: > "Andrew R. Reiter" <arr@watson.org> writes: > > if (chain->fw_flg & IP_FW_F_RND_MATCH) { > > double d = 1.0 * chain->dont_match_prob; > > d = 1 - (d / 0x7fffffff); > > printf("prob %f ", d); > > } > > There is no need for a temporary variable here. The probability > computation can be greatly simplified. BTW, the format string should > specify the number of decimals (e.g. "%.3f"). > > if (chain->fw_flg & IP_FW_F_RND_MATCH) > printf("prob %.3f ", > 1.0 - chain->dont_match_prob / 0x7fffffff); More like: if (chain->fw_flg & IP_FW_F_RND_MATCH) printf("prob %.3f ", 1.0 - (1.0 * chain->dont_match_prob) / 0x7fffffff); otherwise int arithmetic will bite the hell out of that division :) -giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011029195648.G23264>