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

Fix hashing on Julia 1.10 #55

Merged
merged 4 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
- '1.6'
- '1.7'
- '1.8'
- '~1.9.0-0'
- '1.9'
- '~1.10.0-0'
- 'nightly'
os:
- ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master

* ![Maintenance](https://img.shields.io/badge/-maintenance-grey) Implement new `hash` behavior on Julia ≥ 1.10. ([#55](https://github.com/sostock/HalfIntegers.jl/pull/55))

## v1.5.0

* ![Feature](https://img.shields.io/badge/-feature-green) Better support for `Half{T}` where `T` is an integer type that cannot represent the number 2. ([#49](https://github.com/sostock/HalfIntegers.jl/pull/49), [#51](https://github.com/sostock/HalfIntegers.jl/pull/51), [#52](https://github.com/sostock/HalfIntegers.jl/pull/52))
Expand Down
6 changes: 4 additions & 2 deletions src/HalfIntegers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ hashhalf(x::Integer, h::UInt) = invoke(hash, Tuple{Real,UInt}, half(x), h)
# Version for integers with ≤ 64 bits, adapted from hash(::Rational{<:Base.BitInteger64}, ::UInt)
function hashhalf(x::Base.BitInteger64, h::UInt)
iseven(x) && return hash(x >> 1, h)
if abs(x) < 9007199254740992
if Base.uabs(x) < UInt64(maxintfloat(Float64))
return hash(ldexp(Float64(x),-1),h)
end
h = Base.hash_integer(1, h)
@static if VERSION < v"1.10.0-DEV.1448"
h = Base.hash_integer(1, h)
end
h = Base.hash_integer(-1, h)
h = Base.hash_integer(x, h)
return h
Expand Down