[CLJ-1204] hash is inconsistent with = for many BigInteger values Created: 18/Apr/13 Updated: 05/Sep/13 Resolved: 05/Sep/13
|Affects Version/s:||Release 1.4, Release 1.5|
|Patch:||Code and Test|
The function hash is documented to be consistent with =. For many BigInteger values, hash is inconsistent with =. This leads to incorrect behavior for data structures like hash maps that use hash.
|Comment by Andy Fingerhut [ 18/Apr/13 8:10 PM ]|
Patch clj-1204-make-hash-consistent-with-equal-for-bigintegers-v1.txt dated Apr 18 2013 takes the following approach to the issue:
Change the behavior of hasheq so that when given a BigInteger value that could fit into a long, returns the same hash code as that long value.
hasheq continues to return x.hashCode() if the BigInteger value does not fit into a long. This is consistent with the hash value returned by a BigInt value that does not fit into a long.
New tests are included, some of which fail without the change to hasheq, but pass with the change.
|Comment by Andy Fingerhut [ 18/Apr/13 8:19 PM ]|
Overwrite patch with one that leaves out some unnecessary code.
|Comment by Andy Fingerhut [ 25/Apr/13 6:42 PM ]|
Changing priority to minor, since I suppose one could work around this issue, if you were diligent about it, by converting all BigIntegers to BigInts before they are ever used in a place where they are hashed.
|Comment by Andy Fingerhut [ 05/Sep/13 9:00 AM ]|