commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37019] - [math] NaN handling in StatsUtil.min, StatsUtil.max methods
Date Thu, 13 Oct 2005 15:26:53 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37019>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37019





------- Additional Comments From kim@kimvdlinde.com  2005-10-13 17:26 -------
Ok, did some more checks, and the solution before was only dealing with half the
problem:

    public void increment(final double d)
    {
	if (Double.isNaN(value) || Double.isNaN(d))
	    value = Double.NaN;
        else if (d > value)
            value = d;
        n++;
    }

    public double evaluate(final double[] values, final int begin, final int length)
    {
        double max = Double.NaN;
        if (test(values, begin, length))
        {
            max = values[begin];
            for (int i = begin; i < begin + length; i++)
	    {
	        if (Double.isNaN(values[i]))
	            return Double.NaN;
                max = (max > values[i]) ? max : values[i];
            }
        }
        return max;
    }

The solution I added prematurely returns the method as soon as it finds a NaN. 

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message