Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D38011210 for ; Thu, 26 Jun 2014 13:09:20 +0000 (UTC) Received: (qmail 117 invoked by uid 500); 26 Jun 2014 13:09:19 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 99939 invoked by uid 500); 26 Jun 2014 13:09:19 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 99930 invoked by uid 99); 26 Jun 2014 13:09:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2014 13:09:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2014 13:09:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1E44323889FA; Thu, 26 Jun 2014 13:08:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1605777 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java Date: Thu, 26 Jun 2014 13:08:56 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140626130856.1E44323889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erans Date: Thu Jun 26 13:08:55 2014 New Revision: 1605777 URL: http://svn.apache.org/r1605777 Log: MATH-1130 Shortcut (in case one of the arguments is NaN). Thanks to Venkatesha Murthy. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java?rev=1605777&r1=1605776&r2=1605777&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java Thu Jun 26 13:08:55 2014 @@ -159,7 +159,7 @@ public class Precision { * @since 2.2 */ public static boolean equalsIncludingNaN(float x, float y) { - return (Float.isNaN(x) && Float.isNaN(y)) || equals(x, y, 1); + return (x != x || y != y) ? !(x != x ^ y != y) : equals(x, y, 1); } /** @@ -255,7 +255,7 @@ public class Precision { * @since 2.2 */ public static boolean equalsIncludingNaN(float x, float y, int maxUlps) { - return (Float.isNaN(x) && Float.isNaN(y)) || equals(x, y, maxUlps); + return (x != x || y != y) ? !(x != x ^ y != y) : equals(x, y, maxUlps); } /** @@ -280,7 +280,7 @@ public class Precision { * @since 2.2 */ public static boolean equalsIncludingNaN(double x, double y) { - return (Double.isNaN(x) && Double.isNaN(y)) || equals(x, y, 1); + return (x != x || y != y) ? !(x != x ^ y != y) : equals(x, y, 1); } /** @@ -403,7 +403,7 @@ public class Precision { * @since 2.2 */ public static boolean equalsIncludingNaN(double x, double y, int maxUlps) { - return (Double.isNaN(x) && Double.isNaN(y)) || equals(x, y, maxUlps); + return (x != x || y != y) ? !(x != x ^ y != y) : equals(x, y, maxUlps); } /**