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

Ensure that "true" and "false" won't go in same bucket in hash table #3471

Merged
merged 1 commit into from
Sep 12, 2024
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
2 changes: 1 addition & 1 deletion M2/Macaulay2/d/basic.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export hash(e:Expr):hash_t := (
is s:SymbolBody do s.symbol.hash
is x:Database do x.hash
is x:ZZcell do hash(x.v)
is b:Boolean do if b.v then hash_t(444777) else hash_t(777333)
is b:Boolean do Ccode(hash_t, b.v)
is Nothing do hash_t(333889)
is x:List do x.hash
is f:functionCode do f.hash
Expand Down
6 changes: 2 additions & 4 deletions M2/Macaulay2/m2/basictests/hashcodes.m2
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ assert( (hash (1,2,3)) === 568179786079386623 )
assert( (hash [1,2,3]) === 9684772971066268688 )
assert( (hash (3/5)) === 6499208 )
assert( (hash new HashTable from { 1 => 2 , 3 => 4 }) === 14342786426447859 )
assert( (hash true) === 444777 )
assert( (hash false) === 777333 )
assert( (hash true) === 1 )
assert( (hash false) === 0 )
assert( (hash null) === 333889 )
assert( (hash Nothing) === 1000069 )
assert( (hash (1 => 2)) === 1729140528276943882 )
assert( hash Nothing == 1000069 )
assert( (hash Boolean) === 1000035 )
assert( (hash true) === 444777 )
assert( (hash false) === 777333 )

-- these might change if our floating point implementation changes, but let's check anyway:
assert( hash 1.23p200 === 18446744072207201388 -* 64-bit *- or hash 1.23p200 == 18446744073069319069 -* 32-bit *- )
Expand Down
Loading