in reply to Algoritm for converting string to number?

What are the chances of there being two or more of your textual product codes clashing if you transformed them by:

  1. converting all letters to uppercase ascii (eg.A-Z);
  2. stripped out all spaces and punctuation;
  3. truncate them to 13 characters;

If the chances of a collision are low -- and I think they would probably be so low as to be considered negligible -- then you can have a mapping function to a 64-bit int that will cover 36**13 (170,581,728,179,578,208,256) product ids, which is probably enough to be going on with.

Some will say that relying on 'negligible risk' is still "too dangerous", completely failing to recognise that every digest, UUID/GUID etc. relies on exactly that principle.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Algoritm for converting string to number?