[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [jira] Created: (LANG-381) NumberUtils.min(floatArray) returns
From: "Thomas Vandahl (JIRA)" <jira () apache ! org>
Date: 2007-11-30 13:17:43
Message-ID: 26629299.1196428663043.JavaMail.jira () brutus
[Download RAW message or body]
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
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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic