First page Back Continue Last page Graphics
Modulo Arithmetic
Sometimes the numbers just add to be too large:
- Suppose you are hashing arbitrarily long integers. The addition of 999999999999999999999999999999 is 270 and you might only have space for 100 items in the array.
You can simply take the modulo of the resulting number as the address 270%100 = 70. (This is rather asymmetric though)
It is generally wise when using modulo to choose a table size that is a prime number. This increases the chance of uniform distribution over the entire space of the table.