commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: LANG - useful to have float/double equals method?
Date Wed, 12 Jan 2011 16:21:48 GMT
On 12 January 2011 15:31, Ted Dunning <ted.dunning@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 <sebbaz@gmail.com> wrote:
>
>> Would it be useful to add an equals method for float/double?
>>
>

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


Mime
View raw message