Hashing is used to summarize content. There's no guarantee that collisions won't happen if the hashing algorithm creates a hash of fewer bits than the maximum possible entropy in the data set. And for your purposes, you are virtually assured of having collisions. As corion mentioned, you cannot uniquely represent the state of every number between 1 and 100 with fewer than 100 bits (your bit string approach is already an optimal solution if you cannot tolerate information loss). If you use a hashing solution instead, you will have collisions, since 16 bits is an inadequate key size to avoid collisions.
Can you tolerate collisions? Could you solve the problem that motivated this quest by taking a different route entirely (In other words, could this be an X-Y problem?)?
Dave
In reply to Re: coding question
by davido
in thread coding question
by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |