Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 79868 invoked from network); 2 Dec 2007 03:53:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Dec 2007 03:53:19 -0000 Received: (qmail 18810 invoked by uid 500); 2 Dec 2007 03:53:06 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 18742 invoked by uid 500); 2 Dec 2007 03:53:05 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 18733 invoked by uid 99); 2 Dec 2007 03:53:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Dec 2007 19:53:05 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Dec 2007 03:53:15 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 06FA7714201 for ; Sat, 1 Dec 2007 19:52:43 -0800 (PST) Message-ID: <33502130.1196567563005.JavaMail.jira@brutus> Date: Sat, 1 Dec 2007 19:52:43 -0800 (PST) From: "Henri Yandell (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (LANG-381) NumberUtils.min(floatArray) returns wrong value if floatArray[0] happens to be Float.NaN In-Reply-To: <26629299.1196428663043.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12547564 ] Henri Yandell commented on LANG-381: ------------------------------------ Confirmed; and same problem exists for doubles. > NumberUtils.min(floatArray) returns wrong value if floatArray[0] happens to be Float.NaN > ---------------------------------------------------------------------------------------- > > Key: LANG-381 > URL: https://issues.apache.org/jira/browse/LANG-381 > Project: Commons Lang > Issue Type: Bug > Affects Versions: 2.3 > Reporter: Thomas Vandahl > Fix For: 2.4 > > > The min() method of NumberUtils returns the wrong result if the first value of the array happens to be Float.NaN. The following code snippet shows the behaviour: > float a[] = new float[] {(float) 1.2, Float.NaN, (float) 3.7, (float) 27.0, (float) 42.0, Float.NaN}; > float b[] = new float[] {Float.NaN, (float) 1.2, Float.NaN, (float) 3.7, (float) 27.0, (float) 42.0, Float.NaN}; > > float min = NumberUtils.min(a); > System.out.println("min(a): " + min); // output: 1.2 > min = NumberUtils.min(b); > System.out.println("min(b): " + min); // output: NaN > This problem may exist for double-arrays as well. > Proposal: Use Float.compare(float, float) or NumberUtils.compare(float, float) to achieve a consistent result. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.