Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 5866 invoked from network); 1 May 2009 18:15:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 May 2009 18:15:06 -0000 Received: (qmail 29335 invoked by uid 500); 1 May 2009 18:15:06 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 29257 invoked by uid 500); 1 May 2009 18:15:05 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 29246 invoked by uid 99); 1 May 2009 18:15:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2009 18:15:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of danfuzz@google.com designates 216.239.45.13 as permitted sender) Received: from [216.239.45.13] (HELO smtp-out.google.com) (216.239.45.13) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2009 18:14:57 +0000 Received: from zps19.corp.google.com (zps19.corp.google.com [172.25.146.19]) by smtp-out.google.com with ESMTP id n41IEaNp008394 for ; Fri, 1 May 2009 11:14:36 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1241201676; bh=XAVcXNnUEXQ3N49mBuEJCkhc+CU=; h=DomainKey-Signature:MIME-Version:In-Reply-To:References:From:Date: Message-ID:Subject:To:Content-Type:Content-Transfer-Encoding: X-System-Of-Record; b=ZF9pzIDXpd6Lq9s2DR1VeDKjJFeWV95+tHBp5AnLqhEn 282pkhUXpO5qAD63GqXUKjHjzfgPzM/1mYWNVth8Hw== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:from:date:message-id: subject:to:content-type:content-transfer-encoding:x-system-of-record; b=MnvCDkkfhWkTbKXK6Q1qiGpZ/iEKa2YSXxrvXmbTw1TolowDWhnOpX/bvsdSv4/fq YOC5EpJc70y0ojwtDtmuQ== Received: from yw-out-2324.google.com (ywj3.prod.google.com [10.192.10.3]) by zps19.corp.google.com with ESMTP id n41IEYmi017346 for ; Fri, 1 May 2009 11:14:35 -0700 Received: by yw-out-2324.google.com with SMTP id 3so1580536ywj.87 for ; Fri, 01 May 2009 11:14:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.134.10 with SMTP id h10mr6276644and.148.1241201674306; Fri, 01 May 2009 11:14:34 -0700 (PDT) In-Reply-To: <0vqfxfp83c6.fsf@gmail.com> References: <49F80B63.1000504@gmail.com> <49FA1578.7090309@gmail.com> <0vqfxfp83c6.fsf@gmail.com> From: Dan Bornstein Date: Fri, 1 May 2009 11:14:14 -0700 Message-ID: <8084e12c0905011114n51c3535ct19c4fd92d5cffd9c@mail.gmail.com> Subject: Re: Float/Double comparison performance To: dev@harmony.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Virus-Checked: Checked by ClamAV on apache.org On Fri, May 1, 2009 at 4:33 AM, Egor Pasko wrote: > // Non-zero and non-NaN equality checking. > if (float1 =3D=3D float2 && (0.0f !=3D float1 || 0.0f !=3D float2)) { > =A0return 0; > } Would the following be a useful and safe improvement over the above?: if (float1 =3D=3D float2 && 0.0f !=3D (float1 + float2)) { I think this would save at least one test and branch. I'm not an IEEE754 expert, but I think that, given that the two floats are =3D=3D, the second test could only be true if they are both zeroes. -dan