From owner-cvs-all Mon Oct 29 10:37:55 2001 Delivered-To: cvs-all@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 5249D37B403; Mon, 29 Oct 2001 10:37:51 -0800 (PST) Received: from hades.hell.gr (patr530-a151.otenet.gr [212.205.215.151]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id f9TIbf808716; Mon, 29 Oct 2001 20:37:42 +0200 (EET) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id f9THumI28542; Mon, 29 Oct 2001 19:56:49 +0200 (EET) (envelope-from charon@labs.gr) Date: Mon, 29 Oct 2001 19:56:48 +0200 From: Giorgos Keramidas To: Dag-Erling Smorgrav Cc: "Andrew R. Reiter" , Luigi Rizzo , Josef Karthauser , 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> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.22.1i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Oct 29, 2001 at 03:36:38PM +0100, Dag-Erling Smorgrav wrote: > "Andrew R. Reiter" 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