Skip to content

Commit

Permalink
Fix hashing on Julia 1.10 (#55)
Browse files Browse the repository at this point in the history
* Test on Julia 1.10

* Clarify condition

* Implement new hashing behavior in Julia 1.10

* Add changelog item
  • Loading branch information
sostock authored Jul 29, 2023
1 parent b605e1c commit 3f2bd7c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
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

0 comments on commit 3f2bd7c

Please sign in to comment.