From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8813 invoked by alias); 8 Jul 2002 07:00:03 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 8731 invoked from network); 8 Jul 2002 06:59:59 -0000 Received: from unknown (HELO junk.nocrew.org) (213.242.147.30) by sources.redhat.com with SMTP; 8 Jul 2002 06:59:59 -0000 Received: from lars by junk.nocrew.org with local (Exim 3.31 #1 (Debian)) id 17RSUi-0003Ow-00; Mon, 08 Jul 2002 08:59:36 +0200 To: tim@hollebeek.com Cc: Paul Koning , dewar@gnat.com, geoffk@geoffk.org, gcc@gcc.gnu.org Subject: Re: Comparing doubles References: <20020706145326.B4B69F28EB@nile.gnat.com> <15656.15769.42000.732149@gargle.gargle.HOWL> <20020707161828.A13448@hollebeek.com> From: Lars Brinkhoff Organization: nocrew Date: Mon, 08 Jul 2002 02:19:00 -0000 In-Reply-To: <20020707161828.A13448@hollebeek.com> Message-ID: <851yaeaenb.fsf@junk.nocrew.org> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-07/txt/msg00336.txt.bz2 Tim Hollebeek writes: > On Sun, Jul 07, 2002 at 09:09:45AM -0400, Paul Koning wrote: > > As for compare, I don't claim to know the intricacies of IEEE NaN and > > all that, but surely on older float formats at least, compare is > > indeed internally just a subtract and test for zero? > The original suggestion, which seems to be missed by many, was > subtract _doubles_ and compare to _float_ zero. Yes. Some more information about the floating-point format (not IEEE) in question: there are no NaNs, infinities, or -0. FLT_MIN == (float)DBL_MIN. The double format is just a float number with an extra word of mantissa. I think this means that the proposed operation (subtraction followed by truncation and comparison against zero) will only fail if there is an operand that is too small to be normalized. -- Lars Brinkhoff http://lars.nocrew.org/ Linux, GCC, PDP-10, Brinkhoff Consulting http://www.brinkhoff.se/ HTTP programming