You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gilles Sadowski <gi...@harfang.homelinux.org> on 2010/05/06 14:09:17 UTC

[Math] NaN in "equals"

Hello.

In the "MathUtils" class, "equals" methods consider that a NaN is equal to a
NaN. It seems that the orthodox view is that such a comparison should return
"false".
Is there a rationale behind the current behaviour (e.g. it is admittedly
more efficient to not call "Double.isNaN")?
Or can I make the changes in order to comply to IEEE?


Best,
Gilles

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


Re: [Math] NaN in "equals"

Posted by Bill Barker <bi...@verizon.net>.

--------------------------------------------------
From: "Gilles Sadowski" <gi...@harfang.homelinux.org>
Sent: Thursday, May 06, 2010 5:09 AM
To: <de...@commons.apache.org>
Subject: [Math] NaN in "equals"

> Hello.
>
> In the "MathUtils" class, "equals" methods consider that a NaN is equal to 
> a
> NaN. It seems that the orthodox view is that such a comparison should 
> return
> "false".
> Is there a rationale behind the current behaviour (e.g. it is admittedly
> more efficient to not call "Double.isNaN")?
> Or can I make the changes in order to comply to IEEE?
>

Well, that is the convention in most of the library, so would be -1 to 
changing it only in MathUtils since it would then be inconsistent (e.g. 
ArrayRealVector.equals returns "true" if both vectors have a NaN in some 
(not necessarily the same) position.  I would be -0.5 to changing it in a 
point release, since there may be users that are relying on the current 
behavior and point releases are supposed to be drop in replacements.  I 
don't have strong feelings either way for the next major release.

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

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