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

Equality to Float64 NaN failing #104

Open
jaakkor2 opened this issue Oct 6, 2024 · 1 comment
Open

Equality to Float64 NaN failing #104

jaakkor2 opened this issue Oct 6, 2024 · 1 comment

Comments

@jaakkor2
Copy link

jaakkor2 commented Oct 6, 2024

Here equality of NaN_1 to NaN fails

using SentinelArrays

NaN_1 = reinterpret(Float64, 0xffffd10000000000)
NaN_2 = reinterpret(Float64, 0x7ff8000000000000)
SentinelArray([NaN_1, 1.1], NaN, missing) # [NaN, 1.1]
SentinelArray([NaN_2, 2.2], NaN, missing) # [missing, 2.2]

Guessing: here https://github.com/JuliaData/SentinelArrays.jl/blob/v1.4.5/src/SentinelArrays.jl#L184-L185 defines to use === as comparison. Docstring for NaN says

Always use isnan or isequal for checking for NaN. Using x === NaN may give unexpected results

Julia 1.10.5, SentinelArrays v1.4.5

@jaakkor2
Copy link
Author

Commenting out the line https://github.com/JuliaData/SentinelArrays.jl/blob/v1.4.6/src/SentinelArrays.jl#L185

eq(x::T, y::T) where {T <: Real} = x === y

fixes the above bug, and tests pass locally as well.

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

No branches or pull requests

1 participant