Hash Table

How would I be able to store a negative number in hash table?
Would it work the similar to how hash for positive numbers are calculated?
I think you should use unsigned integers for your hash values because you don't want a hash value to be negative. If your hash values are signed integers for some reason you need to make sure that your hash function always returns a positive integer.
Last edited on
It does not matter whether your integers are signed or unsigned.
I think Duoas is correct. I think negative number gets converted to a big number and the hash is calculated on this. Just wanted to confirm if you guys thought the same.
Topic archived. No new replies allowed.