commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject Re: [Math] Use of Precision class for inequalities
Date Wed, 30 Oct 2013 11:44:27 GMT
On Wed, 30 Oct 2013 12:04:06 +0100, Luc Maisonobe wrote:
> Le 30/10/2013 11:45, BIGNON Emmanuel a écrit :
>> Hello,
>
> Hi Emmanuel,
>
>>
>> Commons Math has a class "Precision" that defines equalities and 
>> inequalities using epsilon values.
>> I noticed that Commons Math uses the Precison.equals method when 
>> necessary (for equalities), but never the Precision.compareTo method 
>> (for inequalities).
>> Is there a specific reason for that asymmetrical behaviour?
>
> No, there are no specific reasons. The use of the Precision class
> spreads slowly as we work on various code aspects, but we did not try 
> to
> enforce the change everywhere in one big move.

Isn't the reason that there are more cases where strict floating-point 
equality
leads to buggy code (e.g. infinite loops)?
[There are a couple of cases where Commons Math uses 
"Precision.compareTo" but
I'm not convinced that it was necessary. If not, it just obscures the 
code; if
its usage is really necessary, it would be worth a comment indicating 
why.]


Best,
Gilles


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


Mime
View raw message