-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Floating point hash bug #37800
Comments
julia> function myhash(b)
return hash(ifelse(b, Inf, -Inf), UInt(0))
end
myhash (generic function with 1 method)
julia> myhash(false)
0x15d7d083d04ecb90
julia> myhash(true)
0x15d7d083d04ecb90
julia> hash(-Inf, UInt(0))
0x96e782fc7639e1bc
julia> hash(Inf, UInt(0))
0x807bb202c9cbfc6f |
Seems as if it evaluated |
And it seems like a julia bug. The implementation of |
Ref 3696968 which was an incomplete fix with an incorrect explaination. |
Did some archeology and found 3696968. Kinda funny how this comes back 6 years later. |
Sniped... |
In LLVM (inherited from C), fptosi has undefined behavior if the result does not fit the integer size after rounding down. But by using the same strategy as generic hashing of Real values, we actually can end up with a sitatuion that is faster for the CPU to deal with and avoids the UB. Refs #6624 (3696968) Fixes #37800
In LLVM (inherited from C), fptosi has undefined behavior if the result does not fit the integer size after rounding down. But by using the same strategy as generic hashing of Real values, we actually can end up with a sitatuion that is faster for the CPU to deal with and avoids the UB. Refs #6624 (3696968) Fixes #37800
In LLVM (inherited from C), fptosi has undefined behavior if the result does not fit the integer size after rounding down. But by using the same strategy as generic hashing of Real values, we actually can end up with a sitatuion that is faster for the CPU to deal with and avoids the UB. Refs #6624 (3696968) Fixes #37800
Faster integer hashing (fixes #37800 UB)
With LLVM 9 I get the expected output:
With LLVM 10 I get:
Edit:
0x15d7d083d04ecb90
is the correct hash forNaN
The text was updated successfully, but these errors were encountered: