hi,
when i hash i use _64bit numbers. the size of my tables, hashmax is measured in long. so if i have an int64 key and a long hashmax and do hashkey=key%hashmax i get a possible loss of data warning. hashkey is long too. but since key an int 64 number is being divided by hashmax to produce a long number i always discounted the warning.
am i correct?
Mike
hasing question- warning possible loss of data
Moderator: Ras
-
- Posts: 626
- Joined: Sun May 13, 2007 9:55 pm
- Location: Bay Area, CA USA
- Full name: Mike Adams
-
- Posts: 12777
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: hasing question- warning possible loss of data
The remainder after modulus is less than hashmax in size (by definition of modulus). So if hashmax is equal to or smaller than LONG_MAX as defined in <limits.h> with c (or <limits> with C++) then you should be OK.adams161 wrote:hi,
when i hash i use _64bit numbers. the size of my tables, hashmax is measured in long. so if i have an int64 key and a long hashmax and do hashkey=key%hashmax i get a possible loss of data warning. hashkey is long too. but since key an int 64 number is being divided by hashmax to produce a long number i always discounted the warning.
am i correct?
Mike
Probably, if you explicitly cast the assignment, the warning will vanish.