Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking foo() === NaN is brittle #1055

Closed
KristofferC opened this issue Jan 14, 2020 · 4 comments · Fixed by #1057
Closed

Checking foo() === NaN is brittle #1055

KristofferC opened this issue Jan 14, 2020 · 4 comments · Fixed by #1057

Comments

@KristofferC
Copy link
Member

Tests for Distributions.jl fails on Julia master likely due to the type of NaN that is generated. === on NaN will do a bitwise check. It is likely the tests should use isnan.

@matbesancon
Copy link
Member

I see why we should fix this in the package, but on the Julia side, isn't it a breaking change to now return false on NaN === NaN?

@andreasnoack
Copy link
Member

andreasnoack commented Jan 17, 2020

So NaN === NaN is still true. I guess we might sometimes receive different kinds of NaNs from our dependencies so we end up with something like

julia> nan1 = reinterpret(Float64, 0x7ff8000000000000)
NaN

julia> nan2 = reinterpret(Float64, 0x7ff8000000000001)
NaN

julia> nan1 === nan2
false

but what have changed in Julia 1.4 that could cause this? To clarify, the example here also returns false on older Julia releases so what might have changed is the NaN produced by some of our functions.

@KristofferC
Copy link
Member Author

KristofferC commented Jan 17, 2020

JuliaLang/julia#34405 might make this not happen anymore but haven't checked.

@matbesancon
Copy link
Member

interesting, I thought NaN was a unique bit value, well TIL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants