Behaviour of isapprox and NaN

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Behaviour of isapprox and NaN

axsk
I think of isapprox as a weaker version of isequal, but currently we have:

isequal(NaN, NaN) == true
isapprox(NaN, NaN) == false

In my eyes we should provide:

isapprox(NaN, NaN) == true
isapprox([1, NaN], [1, NaN]) == true
isapprox([1, NaN], [2, NaN]) == false
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of isapprox and NaN

Jameson Nash
I think you want `==` not `isequal`

On Thu, Nov 19, 2015 at 3:56 PM axsk <[hidden email]> wrote:
I think of isapprox as a weaker version of isequal, but currently we have:

isequal(NaN, NaN) == true
isapprox(NaN, NaN) == false

In my eyes we should provide:

isapprox(NaN, NaN) == true
isapprox([1, NaN], [1, NaN]) == true
isapprox([1, NaN], [2, NaN]) == false
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of isapprox and NaN

Steven G. Johnson
In reply to this post by axsk
== is numeric equality.  NaN == NaN gives false, which is correct according to IEEE semantics.  isapprox is a numeric comparison, so it should be weaker than ==

isequal (===) is object identity, so it has different semantics.