Hash Table

Aug 27, 2015 at 3:39am
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?
Aug 27, 2015 at 7:22am
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 Aug 27, 2015 at 7:24am
Aug 27, 2015 at 9:13am
It does not matter whether your integers are signed or unsigned.
Aug 27, 2015 at 1:15pm
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.