[Math] NaN in "equals"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Math] NaN in "equals"

Gilles Sadowski
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] NaN in "equals"

Bill Barker


--------------------------------------------------
From: "Gilles Sadowski" <[hidden email]>
Sent: Thursday, May 06, 2010 5:09 AM
To: <[hidden email]>
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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]