On 12 January 2011 15:31, Ted Dunning <ted.dunn...@gmail.com> wrote:
> Why aren't the comparison methods in java (since 1.4) good enough?

1) LANG 2.x targets 1.3

2) compare does not take into account that floats/doubles are inexact,
so some tolerance is needed.

See http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
for useful explanation.

Furthermore, both compare() and equals() treat +0 and -0 as being unequal.

> http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Double.html#compare(double,
> double)
>
> http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Float.html#compare(float,
> float)
>
> On Wed, Jan 12, 2011 at 3:15 AM, sebb <seb...@gmail.com> wrote:
>
>> Would it be useful to add an equals method for float/double?
>>
>

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

Reply via email to