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

hashCode function in util.HashMap returns same value for an integer and a string containing same integer #28

Open
patrickwestphal opened this issue Jan 12, 2015 · 0 comments
Assignees

Comments

@patrickwestphal
Copy link
Member

The hashCode function of the util.HashMap class generates the same hash for, e.g. 23 and '23' (integer and string type, respectively). In this respect the function behaves differently than many other hash functions, e.g. in
Node

> var md5 = require('MD5');
undefined
> md5(23)
'1fab1cffea9b6fd2f36bfb46e182fd77'
> md5('23')
'37693cfc748049e45d87b8c7d8b9aacd'

Python

>>> hash(23)
23
>>> hash('23')
6400038450057767

and R

> library(hashFunction)
> cityhash.64('23')
[1] 1301089509  153739053
> cityhash.64(as.integer(23))
[1]  1257865039 -2072067122

Moreover it breaks this test.

Is this behaviour intended or a bug?

@patrickwestphal patrickwestphal changed the title hashCode function in util.HashMap returns same value for and integer and a string containing same integer hashCode function in util.HashMap returns same value for an integer and a string containing same integer Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants