File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -848,17 +848,17 @@ if Limb === UInt64 === UInt
848
848
# an optimized version for BigInt of hash_integer (used e.g. for Rational{BigInt}),
849
849
# and of hash
850
850
851
- using . Base: hash_uint
851
+ using . Base: hash_finalizer
852
852
853
853
function hash_integer (n:: BigInt , h:: UInt )
854
854
GC. @preserve n begin
855
855
s = n. size
856
856
s == 0 && return hash_integer (0 , h)
857
857
p = convert (Ptr{UInt64}, n. d)
858
858
b = unsafe_load (p)
859
- h ⊻= hash_uint (ifelse (s < 0 , - b, b) ⊻ h)
859
+ h ⊻= hash_finalizer (ifelse (s < 0 , - b, b) ⊻ h)
860
860
for k = 2 : abs (s)
861
- h ⊻= hash_uint (unsafe_load (p, k) ⊻ h)
861
+ h ⊻= hash_finalizer (unsafe_load (p, k) ⊻ h)
862
862
end
863
863
return h
864
864
end
Original file line number Diff line number Diff line change @@ -808,3 +808,11 @@ t = Rational{BigInt}(0, 1)
808
808
@test Base. GMP. MPQ. div! (- oo, zo) == - oz
809
809
end
810
810
end
811
+
812
+ @testset " hashing" begin
813
+ for i in 1 : 10 : 100
814
+ bint = big (11 )^ i
815
+ bfloat = big (11.0 )^ i
816
+ @test (hash (bint) == hash (bfloat)) == (bint == bfloat)
817
+ end
818
+ end
You can’t perform that action at this time.
0 commit comments