help for problem of module with "%"

Quote:

> This is question that really bothered for some time when I use hashing

> functions.

> I have a data with 13 digits(bad luck number!), and I read it in as

> "double"

> Since "%" require integer, so I casted the double to integer by (int)

> a%b.

> It seemed working, but not proper. I then treated 13 digits as

> characters and the results seems much better.

> Who can tell me if double could be use like double%int, i.e. in a

> hashing function?

First of all, % can be applied to floating values.

However, % is *not* a "hashing" operator; it's a "remainder"

operator (modulo operation, for nonnegative operands).

The key to understanding your situation is to understand

how integer remainder can be used in a hashing scheme, and

indeed to understand what the purpose of hashing is; once

you fully understand that, you should be able to figure out

whether and how the % operator could be used in hashing

quantities of types other than integer types.

--